一组CheckBox实现单选

加个GroupBox(或其它容器) 把几个CheckBox 放到容器中。CheckBox_CheckedChanged事件指定下面方法:

 

private void CheckBox_CheckedChanged(object sender, EventArgs e) {

            if ((sender as CheckBox).Checked == true) {

                foreach (CheckBox chk in (sender as CheckBox).Parent.Controls) {

                    if (chk != sender) {

                        chk.Checked = false;

                    }

                }

            }

        }

相关文章:

  • 2022-02-04
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案