[英]How Can I get by simple code the Checked RadioButton From Group of RadioButtons Located in same panel in C#?
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 code instead of checking every Radio Button in each group whether it is checked or not ? 我有一个包含多个面板的C#Windows窗体应用程序,每个面板包含一组单选按钮。是否有一种简单的方法来通过代码仅获取选中的单选按钮,而不是检查每个组中的每个单选按钮是否被选中? please help. 请帮忙。 Thanks 谢谢
Try this: 尝试这个:
foreach(Control control in panel.Controls)
{
RadioButton radioButton = control as RadioButton;
if (radioButton != null && radioButton.Checked)
return radioButton;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.