I have a form that contains two elements: a CheckedListBox and a CheckBox. The CheckBox, which is called SelectAllCheckBox, is used to check/uncheck all items in the CheckedListBox. I achieve this via a CheckedChanged event handler associated with the SelectAllCheckBox, so that when it is checked, all items in the CheckedListBox are checked, and vice versa. This works fine.
I also have code that unchecks the SelectAllCheckBox when the user unchecks one of the CheckBoxes in the CheckedListBox. For example, if the user checks the SelectAllCheckBox, and then unchecks one of the items, the Select All CheckBox should be unchecked. This is achieved via the CheckedListBox.ItemChecked event handler. This also works fine.
My problem is that when the SelectAllCheckBox is programatically unchecked (as in the above scenario), its event handler causes all items in the CheckedListBox to become unchecked.
I'm sure others have run into my issue; is there an elegant workaround?