Bug? [4.2 Beta] ChoiceBox & ListView bug

LWGShane

Well-Known Member
Licensed User
Longtime User

Daestrum

Expert
Licensed User
Longtime User
If you check if index < 0 if true then return. I had this in a program too.
It appears to detect the initial change of items(adding etc) and triggers the event.
As the user can only select what is in the list, index of -1 is not so important as for other controls.

B4X:
Sub ProjectOptionsBox_SelectedIndexChanged(Index As Int, Value As Object)
    If Index < 0 Then Return
.....

Just noticed you set the selectedindex to 0 when initializing the data for the control (I did the same) , change it to -1 and the problem goes away.
That explains why it fired the event, it went from -1 (no item selected) when the data was loaded into it, to 0 when (we) set the selectedIndex = 0.

B4X:
        ...
    ProjectTypeList.Items.Add("iOS")
    ProjectOptionsBox.Items.Add("Project Type")
    ProjectOptionsBox.SelectedIndex = -1  ' <<<<<<<<<<<     this was set to 0
    ControlNameField.Enabled = False
        ...
 
Last edited:
Top