Bug or Behavior?
When using a CheckedListBox control, you might not want to use the ItemCheck event. Instead, use the standard SelectedIndexChanged event. Here's why:
- You are using a CheckedListBox control to simulate multiple selection from a list.
- When an item check status is changed, you want to do some operation about it. For example, count the items checked.
If you use the ItemCheck event, you will get the status of items BEFORE the last check operation is commited. For example, you have a two item list box, named “A” and “B”. When you check “A”, the control raise ItemCheck event, changed the check status, and the raise the SelectedIndexChanged.
If you used the ItemCheck event, the CheckedItems property will return 0 items checked (incorrect, or more precise, unwanted). But if you used the SelectedIndexChanged event, the CheckedItems property will return 1 items checked (correct).