【发布时间】:2023-03-03 06:30:20
【问题描述】:
我有一个带有几个单选按钮的表单,它们假设代表不同的整数值。
1) 是否有一种内置 方法可以将值“置于”单选按钮的“后面”? 一个例子:
RadioButton rad = new RadioButton();
rad.Value = 5; // This is what im trying to achieve.
2) 我有几个在逻辑上相互关联的 RadioButton,我想知道选择了哪个(没有将它们放在 GroupBox 控件中)并获取该 RadioButton 的选定值。 注意:我想“迭代”这 3 个控件并获取选定的控件,而不是执行 3 个 IF 语句。 一个例子:
RadioButton radColor1 = new RadioButton();
RadioButton radColor2 = new RadioButton();
RadioButton radColor3 = new RadioButton();
// ...
RadioButton radSelected = ?? // Get selected Radio Button from the 3 above.
//here i can get to radSelected.Value
【问题讨论】:
-
您的问题包含两个不同的主题。请下次发布两个单独的问题。
标签: c# .net winforms radio-button controls