Stop comboBox's selectedIndexChanged event from firing when the form loads

If you want to react only when the user change the selected item in the combo box, then it is better to subscribe to SelectionChangeCommitted.


You can simply unbind the SelectedIndexChanged event, call your fill function and bind the SelectedIndexChanged event again. Unfortunately, this doesn't work with a grid.

For example:

this.cmb.SelectionChanged -= new System.EventHandler(this.cmb_SelectionChanged);
cmb.fill(); //Your function
this.cmb.SelectionChanged += new System.EventHandler(this.cmb_SelectionChanged);

Be sure to set the DataSource property in your onload() function after assigning the ValueMember and Datamember properties.

This will help you to solve your problem!