简体   繁体   English

如何通过简单的代码从C#的同一面板中的RadioButtons组中获取Checked RadioButton?

[英]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.

相关问题 如果选中了组的单选按钮,如何获取? - How can I get if a radiobutton of a group is checked? 如何取消选中 C# 中的单选按钮,同时仍然只允许第一个单选按钮可选项卡? - How can I uncheck radiobuttons in C# while still allowing only the first radiobutton to be tabbable? C#:如何避免多个选中的单选按钮 - C#: How to avoid multiple checked RadioButtons 如何从已定义的单选按钮组中找到选定的单选按钮 - How can I find selected radiobutton from defined group of radiobutton 如何为单选按钮分配一个 id 并在 Xamarin Forms 后面的代码中访问它,以便不检查两个单选按钮 - How can I assign an id for radiobutton and access it at code behind in Xamarin Forms in order to not check both radiobuttons 所有单选按钮均已检查c# - All radiobuttons are checked c# 不确定如何获取在 C# 代码中创建的单选按钮的值 - Not sure how to get value of radiobuttons created in C# code 获取C#中单选按钮和复选框的检查值 - Get Checked Value for Both RadioButtons and CheckBoxes in C# 如何使用 windows forms c# 中的按钮更改单选按钮组中的选中项? - How to change checked item in radiobutton group with buttons in windows forms c#? 我在工作室代码中使用 C#,如何从列表视图中的选中列中获取内容? - I'm using C# in studio code, how to get content from checked column in listview?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM