How to get value of Radio Buttons?

后端 未结 7 1335
自闭症患者
自闭症患者 2020-12-30 05:05

I have a group box contains radio buttons eg.

o Male

o Female

i want my code to get the sel

7条回答
  •  独厮守ぢ
    2020-12-30 05:35

    I found that using the Common Event described above works well and you could have the common event set up like this:

    private void checkChanged(object sender, EventArgs e)
        {
            foreach (RadioButton r in yourPanel.Controls)
            {
                if (r.Checked)
                    textBox.Text = r.Text;
            }
        }
    

    Of course, then you can't have other controls in your panel that you use, but it's useful if you just have a separate panel for all your radio buttons (such as using a sub panel inside a group box or however you prefer to organize your controls)

提交回复
热议问题