I have a CheckedBoxList. Also I have a ItemCheck
event attached to it, so a fuction is executed after I checked an item. But the problem is, at one point in my program I need to programmatically check/uncheck items. And this action triggers the event function.
My guess is is also applies to other controls.
How can I prevent such behaviour? I need function to be run only when user interacts with it, not when I am doing something with control inside my app.
You can wrap all your changes to CheckedBoxList in a function and use that function everytime. The code may look something like this:
private void UpdateCheckedListBox() // You would need to add your parameters
{
checkedListBox1.ItemCheck -= checkedListBox1_ItemCheck;
// your changes to checked list box goes here
checkedListBox1.ItemCheck += checkedListBox1_ItemCheck;
}
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