3 つのチェックボックスがあり、そのうちの 1 つがチェックされていれば 2 つをオフにできます。しかし、3 つ目がチェックされている場合は、最初の 2 つをオフにする必要があります。どうやってやるの?
これが私が試みていることです。
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;
}
コードの最後の部分が機能しません。最初の 2 つのチェックボックスをオフにする必要があります。
ありがとう