SelectedValueChange () event selected during form loading in a Windows Form application

I had a problem when the SelectedValueChanged () event on a ComboBox is fired while my Windows Form application is loading. I currently also have a Form_Load () event that loads several ComboBoxes, including this one, using OleDbDataAdapters / DataTables / Fill (), etc.

I assume that due to my Form_Load () method, the SelectedValueChanged event is fired due to the filling of the populated ComboBox.

Why is this happening?

+5
source share
3 answers

comboBox, . .

Form_Load(..)
{
     _comboBoxName.SelectedValueChanged -= _comboBoxName_SelectedValueChanged;

    // Load data to the combo box... 

    _comboBoxName.SelectedValueChanged += _comboBoxName_SelectedValueChanged;
}
+4

, , - , ComboBox. .

- , . (, FormLoaded = true).

+3
rbtalldivision_CheckedChanged(sender, e);
rbtAllSitecodes_CheckedChanged(sender, e);

Windows

0

All Articles