I am using CheckedListBox
in C# Window Forms Application.
I want to do something after one item checked or unchecked but ItemCheck
event runs before the item checked/unchecked .
How can I do that?
I am using CheckedListBox
in C# Window Forms Application.
I want to do something after one item checked or unchecked but ItemCheck
event runs before the item checked/unchecked .
How can I do that?
You can hook up an event on ItemCheck. You can do it by right clicking your checkboxlist and select properties. And at the right side you will see the property tab, click the event tab button and locate ItemCheck event and double click it. It will generate a event method for you depend on your checkboxlist name like below.
Then, you can verify selected/checked checkbox using code below.
To run some codes after the item checked, you should use a workaround.
Best Option
You can use this option (Thanks to Hans Passant for this post):
Another option
If in middle of ItemCheck Event, you need to know state of item, you should use
e.NewValue
instead of usingcheckedListBox1.GetItemChecked(i)
If you need to pass a list of checked indices to a method do this:
Using the code:
Another Option
In middle of ItemCheck event, remove handler of ItemCheck, SetItemCheckState and then add handler egain.
Try searching more for answers, cause here it is
And the link: Which CheckedListBox event triggers after a item is checked?