Sunday, 15 September 2013

CheckBox in C# Windows App

CheckBox in C# Windows App

I have 3 checkboxes and I am able to turn two of them off if one is
checked. But I want that if the 3rd one is checked then the first two
should be turned off. how can I do that?
This is what I am trying.
private void chkResFoodVeg_CheckedChanged(object sender, EventArgs e)
{
//disables the other checkbox if one is checked
this.chkResFoodNveg.Enabled = !this.chkResFoodVeg.Checked;
}
private void chkResFoodNveg_CheckedChanged(object sender, EventArgs e)
{
this.chkResFoodVeg.Enabled = !this.chkResFoodNveg.Checked;
}
private void chkResFoodBoth_CheckedChanged(object sender, EventArgs e)
{
this.chkResFoodBoth.Enabled = !this.chkResFoodNveg.Checked &&
!this.chkResFoodVeg.Checked;
}
The last part of code doesn't work. It should turn off the first two
checkboxes.
Thanks

No comments:

Post a Comment