Maxford Shentles

I have a combo box which is bound to a data table. The binding (and therefore filling of the items) of the combo box happens in my Form.Load event.

I also have a method for the combobox.selectedIndexChanged event. When the combo box is being filled during the form loading (before the form is displayed on screen), it triggers the IndexChanged event. Due to the nature of my program this presents some problems.

Is it possible to tell a control (or a whole form) to ignore some or all events durinc a certain time

I did get my program to work properly by having a class variable called "loaded" which starts as false, and is set to true in the last line of Form.Load. The combobox event then checks if the loaded variable is true before doing it's work. this works but to me it seems a bit messy. Maybe it's the only way to do it, I dunno.

Help would be much appreciated. Thanks.



Re: .NET Base Class Library Can I ignore events during form loading?

Mattias Sjogren

Another way is to not add the SelectedIndexChanged event handler until the end of your Load method.






Re: .NET Base Class Library Can I ignore events during form loading?

Maxford Shentles

Ah, that makes a lot of sense, thanks.