Android Question Combobox TextChanged event not firing

mike1209

Member
Licensed User
Hi
I have a combox on my main screen, but I cannot get the combo to fire the TextChanged event, I've done a mock up of my screen as a demo, code below, am I missing something?

B4X:
Sub Process_Globals
End Sub

Sub Globals
    Private cboLocation As B4XComboBox
End Sub

Sub Activity_Create(FirstTime As Boolean)     
    Activity.LoadLayout("MainPage")
End Sub

Sub Activity_Resume
    Dim List1 As List
    List1.Initialize
    List1.Add("Finishing Mezzanine")
    List1.Add("Primary Mezzanine")
    List1.Add("Racking Bays")
    List1.Add("Shed 1")
    List1.Add("Shed 2")
    List1.Add("Tullion")
    List1.Add("Yard")
        
    cboLocation.SetItems(List1)
End Sub

Sub cboLocation_TextChanged(Old As String, New As String)
    Try
        Msgbox("text changed","Info")
        If New = "Yard" Then
            Msgbox("Not allowed","NO")

        End If
    Catch
        Msgbox(LastException.Message, "Error")
    End Try
    
End Sub
 

Mahares

Expert
Licensed User
Longtime User
Sub cboLocation_TextChanged(Old As String, New As String)
There is no such event. You can do something like this:
B4X:
Sub cboLocation_SelectedIndexChanged (Index As Int)
    If cboLocation.GetItem(Index) ="Yard" Then
        MsgboxAsync("Not allowed", "Warning")
        'cboLocation_SelectedIndexChanged(0)
        Return
    Else
        Log(cboLocation.GetItem(Index))
    End If
End Sub
 
Upvote 0

mike1209

Member
Licensed User
There is no such event. You can do something like this:
B4X:
Sub cboLocation_SelectedIndexChanged (Index As Int)
    If cboLocation.GetItem(Index) ="Yard" Then
        MsgboxAsync("Not allowed", "Warning")
        'cboLocation_SelectedIndexChanged(0)
        Return
    Else
        Log(cboLocation.GetItem(Index))
    End If
End Sub
Ah..sorry should have picked up on that... thank you for the reply/assistance
 
Upvote 0
Top