If one checkbox is checked, set the other to unchecked

前端 未结 9 1654
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:55

    I suggest you use check_click instead of check_changed

            private void checkBox1_Click(object sender, EventArgs e)
            {
                checkBox2.Checked = false;
                checkBox3.Checked = false;
            }
    
            private void checkBox2_Click(object sender, EventArgs e)
            {
                checkBox1.Checked = false;
                checkBox3.Checked = false;
            }
    
            private void checkBox3_Click(object sender, EventArgs e)
            {
                checkBox1.Checked = false;
                checkBox2.Checked = false;
            }
    

提交回复
热议问题