I have a little problem when loading a ComboBox.
The question is that in the phase of loading data, the default selectedIndex event fires.
How can I prevent this during the load process?
I have a little problem when loading a ComboBox.
The question is that in the phase of loading data, the default selectedIndex event fires.
How can I prevent this during the load process?
I suggest to use a global variable
Boolean isLoaded = false;
in your selectedIndexChange add this code
if(!isLoaded)
{
isLoaded = true;
}
else
{
/// write your code here
}
I would remove the event and re add it after the loading of the data is completed.
combo.SelectedIndexChanged -= combo_SelectedIndexChanged;
//Do the loading of the data into the combo
combo.SelectedIndexChanged += new EventHandler(combo_SelectedIndexChanged);