LWGShane Well-Known Member Licensed User Longtime User Feb 3, 2016 #1 I have a ChoiceBox and ListView. I'm using the SelectedIndexChanged method and my "If" statement causes my app to crash upon selecting a value in the ListView. This is a very weird bug. The project is attached. (Have to upload to OneDrive. There isn't any error messages in the file uploader if it's too big.) OneDrive Link: https://onedrive.live.com/redir?res...7152&authkey=!AFdiokdFEG_4Z98&ithint=file,zip
I have a ChoiceBox and ListView. I'm using the SelectedIndexChanged method and my "If" statement causes my app to crash upon selecting a value in the ListView. This is a very weird bug. The project is attached. (Have to upload to OneDrive. There isn't any error messages in the file uploader if it's too big.) OneDrive Link: https://onedrive.live.com/redir?res...7152&authkey=!AFdiokdFEG_4Z98&ithint=file,zip
Erel B4X founder Staff member Licensed User Longtime User Feb 4, 2016 #2 Please post the SelectedIndexChanged code and the error message.
Daestrum Expert Licensed User Longtime User Feb 4, 2016 #3 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. Code: Copy 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. Code: Copy ... ProjectTypeList.Items.Add("iOS") ProjectOptionsBox.Items.Add("Project Type") ProjectOptionsBox.SelectedIndex = -1 ' <<<<<<<<<<< this was set to 0 ControlNameField.Enabled = False ... Last edited: Feb 4, 2016
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. Code: Copy 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. Code: Copy ... ProjectTypeList.Items.Add("iOS") ProjectOptionsBox.Items.Add("Project Type") ProjectOptionsBox.SelectedIndex = -1 ' <<<<<<<<<<< this was set to 0 ControlNameField.Enabled = False ...