C# ComboBox: Prevent/Stop SelectedIndexChanged event automatically from firing when DataSource is used

Hmmm…

So many people are facing the same issue… The issue is whenever a list is assigned to ComboBox through DataSource in C# winforms, ComboBox’s SelectedIndexChanged event automatically fires up.

How to stop/prevent it? Simple… Just use SelectionChangeCommitted instead of SelectedIndexChanged event.

That’s it! Give it a try!!

Advertisements

5 thoughts on “C# ComboBox: Prevent/Stop SelectedIndexChanged event automatically from firing when DataSource is used

    • How did you change it to the SelectionChangeCommitted event? I do not know where SelectedIndexChanged event is being called.

      • Hi Grant,
        Select your combo box, go to properties window, Clici the “Events” button, Search “SelectionChangeCommitted” and double click on it. Visual Studio will generate a new event for the combo box.

  1. we can also remove the event and then attach again after datasource assigned to combo
    like this way
    combo1_selectedindexchange -= ………………
    combo1.datasource = datatable;
    combo1_selectedindexchange += ……………..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s