If one checkbox is checked, set the other to unchecked

前端 未结 9 1655
Happy的楠姐
Happy的楠姐 2021-01-13 10:06

I have two checkboxes on my form; chkBuried and chkAboveGround. I want to set it up so if one is checked, the other is unchecked. How can I

9条回答
  •  暖寄归人
    2021-01-13 10:46

    The best option and easiest way for me was to create a Click event instead of a CheckedChanged event. This method works perfectly with two or more checkbox and allows to have them all unchecked.

        private void chkOne_Click(object sender, EventArgs e)
        {
            chkTwo.Checked = false;
        }
    
        private void chkTwo_Click(object sender, EventArgs e)
        {
            chkOne.Checked = false;
        }
    

提交回复
热议问题