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

StackTrace picture StackTrace · Jul 16, 2010 · Viewed 83.1k times · Source

I have a form with a ComboBox that provides a dropdownlist. On the comboBox's SelectedIndexChanged event, am running some code, but I don't want that code to run when the form loads. Unfortunately, when I load the form (before I make a selection in the combobox), SelectedIndexChanged of the combobox fires (I think when the combobox is databinding). Is there a way of avoiding such behaviour?

Answer

arbiter picture arbiter · Jul 16, 2010

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.