Cody
Cody

Reputation: 63

CheckedListBox ItemCheck event only fires on fast double click?

If you have a CheckedListBox with CheckOnClick = False the ItemCheck event will not fire when the item is checked IF it is first selected...pause...then click again to check the item. But if it is a quick double click with no pause the event will fire.

Is this the correct behavior? The ItemCheck event should fire regardless of the click speed, right?

I believe this is strange behavior that is easy to replicate:

  1. Make a new winform
  2. add a CheckedListBox and add some items to it. (Leave the default check on click to false)
  3. add a label
  4. subscribe to ItemCheck event and SelectedIndexChanged make the label's text change when each event fires.

Has anyone else ran into this issue?

EDIT 5/1/2015

The problem is that the SelectedIndexChanged event gets fired directly after the ItemCheck event. That means it gets fired before every ItemCheck and then immediately after. The label will not show the change as it happens too fast, but switching to MessageBox.Show() verifies that it is getting fired directly after.

Upvotes: 0

Views: 1448

Answers (2)

Cody
Cody

Reputation: 63

The problem is that the SelectedIndexChanged event gets fired directly after the ItemCheck event. That means it gets fired before every ItemCheck and then immediately after. The label will not show the change as it happens too fast, but switching to MessageBox.Show() verifies that it is getting fired directly after.

Upvotes: 1

nayef harb
nayef harb

Reputation: 753

according to MSDN checkedlistbox.checkonclick (read the remarks section) check on click property controls whether the list box item is checked on the first click or on the second click. in your case where check on click is flase it requires two clicks to check the item thus firing the ItemCheck event.

Upvotes: 0

Related Questions