B4J Question How to get the Index of Item in ComboBox

AndroidMadhu

Active Member
Licensed User
Hi,
I am working with combobox.
I am able to fill combobox by using below :
B4X:
Private Sub btn1_Click
    'xui.MsgboxAsync("Hello world!", "B4X")
    Dim item As List
    item.Initialize
    For i = 1 To 10
        item.Add(i)
        For Each itemnode As Int In item
            cbo1.Items.Add("ItemNo " & itemnode)
        Next
        item.Clear
    Next
End Sub

I want to get the Index of the Items from combo when click on that item.
How to get the indexes?

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
dim l as list =cbo1.Items
dim index as int = l.indexof("ItemNo " & itemnode)

You really should start learning the language
 
Upvote 0

AndroidMadhu

Active Member
Licensed User
B4X:
dim l as list =cbo1.Items
dim index as int = l.indexof("ItemNo " & itemnode)

You really should start learning the language
I did this like below. But I thought the same is not correct way...
B4X:
Private Sub cbo1_SelectedIndexChanged(Index As Int, Value As Object)
    Log("index value: " & cbo1.SelectedIndex & " " & Value)
End Sub

Thanks for the update
 
Upvote 0
Top