J jimseng Active Member Licensed User Longtime User Sep 20, 2025 #1 I am trying to fetch the currently selected index of a combo box from another subroutine, not the SelectedIndexChanged event. It seems that it only works once after the event has been triggered. From then on the result is always 0, regardless of which item is actually selected in the combo box. Is it possible to get the currently selected index of a combo box programmatically? B4X: Copy Private Sub cmbHuman_SelectedIndexChanged (Index As Int) Log("index " & Index) Log("selectedIndexChanged " & cmbHuman.SelectedIndex) End Sub Log window: index 1 selectedIndexChanged 1 B4X: Copy Sub getindexes() Log("selectedindex " & cmbHuman.SelectedIndex) End Sub Log window: selectedindex 1 (first time subroutine is run after SelectedIndexChanged event) selectedindex 0 (returns 0 until the item is changed)
I am trying to fetch the currently selected index of a combo box from another subroutine, not the SelectedIndexChanged event. It seems that it only works once after the event has been triggered. From then on the result is always 0, regardless of which item is actually selected in the combo box. Is it possible to get the currently selected index of a combo box programmatically? B4X: Copy Private Sub cmbHuman_SelectedIndexChanged (Index As Int) Log("index " & Index) Log("selectedIndexChanged " & cmbHuman.SelectedIndex) End Sub Log window: index 1 selectedIndexChanged 1 B4X: Copy Sub getindexes() Log("selectedindex " & cmbHuman.SelectedIndex) End Sub Log window: selectedindex 1 (first time subroutine is run after SelectedIndexChanged event) selectedindex 0 (returns 0 until the item is changed)
J jimseng Active Member Licensed User Longtime User Sep 20, 2025 #2 And I get the same behavior with a spinner. Upvote 0
J jimseng Active Member Licensed User Longtime User Sep 20, 2025 #3 My emails shows this response from Daestrum, but I can't see it on this thread for some reason. Just tried the combobox it's working as expected When first displayed combobox.SelectedIndex returns -1 >> none selected After an entry is selected it returns the correct index (zero based) Click to expand... Anyway, so it turns out I am an idiot. I was reloading the combobox each time I ran the test. Sorry to have wasted people's time. Upvote 0
My emails shows this response from Daestrum, but I can't see it on this thread for some reason. Just tried the combobox it's working as expected When first displayed combobox.SelectedIndex returns -1 >> none selected After an entry is selected it returns the correct index (zero based) Click to expand... Anyway, so it turns out I am an idiot. I was reloading the combobox each time I ran the test. Sorry to have wasted people's time.
Daestrum Expert Licensed User Longtime User Sep 20, 2025 #4 I did post then deleted it as I spotted it was Android you were asking about. Upvote 0