I have ComboBox control(WinForm project).
When I bind DataSource to the ComboBox control combobox_selectedindexchanged event is fired.
Any idea how to prevent selectedindexchanged event when DataSource is bound?
You can simply unbind the SelectedIndexChanged event, call your fill function and bind the SelectedIndexChanged event again.
Remove the handler for the SelectedIndex_Changed event, bind your data, then add the handler back. Following is a simple example of how this might be done within a method:
private void LoadYourComboBox() { this.comboBox1.SelectedIndexChanged -= new EventHandler(comboBox1_SelectedIndexChanged); // Set your bindings here . . . this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With