How do I get which radio button is checked from a groupbox?

后端 未结 5 1982
你的背包
你的背包 2020-12-09 16:52

I have these groupboxes:

\"Enter

I want to run some code according to checked

5条回答
  •  清歌不尽
    2020-12-09 17:23

    Rather than checking all RadioButtons, use the Validated event of the GroupBox.

    private void grpBox_Validated(object sender, EventArgs e)
        {
            GroupBox g = sender as GroupBox;
            var a = from RadioButton r in g.Controls where r.Checked == true select r.Name;
            strchecked = a.First();
         }
    

提交回复
热议问题