CheckBox - How to cancel a event?

  • Thread starter Thread starter SQLNewbie
  • Start date Start date
S

SQLNewbie

Scenario:

I have a checkbox, if flag=1, check it(as usual, no extra coding is needed),
otherwise keep old status and give Message to user.

Any way to do it?

Thanks in advance!
 
Hi
Scenario:

I have a checkbox, if flag=1, check it(as usual, no extra coding is needed),
otherwise keep old status and give Message to user.

1. Set *AutoCheck* property of your checkbox to "false"
2. Write handle to *Click* event with checking flag status e.g.:

private void checkBox1_Click(object sender, System.EventArgs e)

{
if( flag==1 ) {
checkBox1.Checked=!checkBox1.Checked;
}
else {
// Message stuff
}
}

*Click* event handles "spacebar" too...

Marcin
 
Thanks.

The key is AutoCheck property.


Marcin Grzêbski said:
Hi


1. Set *AutoCheck* property of your checkbox to "false"
2. Write handle to *Click* event with checking flag status e.g.:

private void checkBox1_Click(object sender, System.EventArgs e)

{
if( flag==1 ) {
checkBox1.Checked=!checkBox1.Checked;
}
else {
// Message stuff
}
}

*Click* event handles "spacebar" too...

Marcin
 
Back
Top