I want to change Checkbox value without raising the onCheck event. I know there are work arounds like un registering ,changing the value then re- registering, Inside the event method based on flag either skip or evaluating the method statements or any other work arounds. I am looking for a cleaner ways for it.
I know this is an old thread but the answer given is way too much trouble.
I almost never use the OnCheckedChanged event. I prefer to use OnMouseUp instead. That way you can set check boxes or radio buttons like you want them on startup without triggering the events.
In the OnMouseUp event check to see if the box is checked after the mouseUp happens like this..
private void chkBox1_MouseUp(object sender, MouseEventArgs e)
{
if (chkBox1.Checked)
{
// do some stuff if the box is checked after a mouseup on it
}
}
I've been doing it this way for a long time. It use to be a big hassle to put flag variables in OnChanged Events to tell functions not to do anything while we are setting the box states. Using MouseUp is way easier. gc
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