winform中CheckBox实现单选(转载)

一组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;

                    }

                }

            }

        }

原文地址:https://www.cnblogs.com/wenjie/p/3044736.html