I have a ListBox in my winforms app and I need to handle the ItemChecked becaue each time the users cliks an item i need to some stuff. The problem is that I also need to change the Checked property in some other events of the form. In those cases I need to avoid do that stuff.
Example:
private void listBox1_ItemChecked(object sender, ItemCheckedEventArgs e)
{
if (true) //Should check if item was clicked.
{
//Do some stuff
}
else //If the event was fired because I changed the Checked property from the code
{
//Do some other stuff
}
}
Thanks
One way would be to use a bool variable let’s say ManualRaise. When you are raising the event through code, set ManualRaise = true and inside your event you can check ‘
and in that event where you will raise the list box event, set the ManualRaise to true.