开发者

How Can I get by simple code the Checked RadioButton From Group of RadioButtons Located in same panel in C#?

开发者 https://www.devze.com 2023-01-03 01:52 出处:网络
I\'ve a C# Windows Form Application that contains multiple Panels , each panel contains group of Radio Buttons.Is There a simple way to get just the checked RadioButton by c开发者_Python百科ode instea

I've a C# Windows Form Application that contains multiple Panels , each panel contains group of Radio Buttons.Is There a simple way to get just the checked RadioButton by c开发者_Python百科ode instead of checking every Radio Button in each group whether it is checked or not ? please help. Thanks


Try this:

foreach(Control control in panel.Controls)
{
    RadioButton radioButton = control as RadioButton;
    if (radioButton != null && radioButton.Checked)
        return radioButton;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消