Does anyone know of a reliable way to cancel the ItemCheck event on a CheckedListBox? I am in a situation where the ItemCheck event should basically discard changes on a form, however, if the person decides to cancel the discard I would like the ItemCheck event not to fire so as not to change anything.
It is easy to do with the ItemCheck event. Just set the value back. Like this:
    private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) {
        if (someCondition) e.NewValue = e.CurrentValue;
        else {
            // Regular stuff
            //...
        }
    }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With