views:

394

answers:

2

I have a ListView where each item has a checkbox. Initially there are no events attached and I set the state of the checkboxes programatically. After this I attach an ItemCheckedEventHandler and the event handler fires for each of the events that occurred before the handler was attached. Is there a way that I can clear the event queue before attaching the handler?

A: 

It's hacky, and I don't like it, but Application.DoEvents() might work for you.

Michael Meadows
+2  A: 

I was able to re-create when the event was added in the form constructor/InitializeComponent method.

And I was able to get around the problem by adding the event in the form's load event instead of the constructor/InitializeComponent method.

Hope that helps.

Chris Persichetti
That worked thanks!
jwarzech