I am using this code provided by
@Mahares which works as expected Except the B4XComboBox1_SelectedIndexChanged only fires AFTER the second change.
Dim lstItems As List
lstItems.Initialize
Dim rs As ResultSet
Do While rs.NextRow
If rs.GetString("n").Contains("1") Then
lstItems.Add(cs.Initialize.Color(Colors.Green).Append(rs.GetString("n")).PopAll)
Else
lstItems.Add(cs.Initialize.Color(Colors.Red).Append(rs.GetString("n")).PopAll)
End If
Loop
rs.close
B4XComboBox1.SetItems(lstItems)
I have found the same issue from this thread but it was never answered.
Same issue
Greetings,
Yeah, as I understand it, the selected index change only fires when there is a change of selection. Since the first item is set as the selected item with an index of 0 pressing it generates no change so the change event is not generated.
I have a list of URLs so what I do is have the 0 index item with the following placeholder text:
Items.Add("Select a URL from list to view")
That works for me but may or not fit your list functionality.
An alternative which may be more in line with your functionality is to set the selected index to -1 after you have added the list of items.
For me that would be cbURLs.SelectedIndex = -1
Then when the 0 index item is selected the event will fire as the index will change to 0. That seems to work as I just did a quick test.
Hope this helps!