【问题标题】:Get selected RadioButton inside a group获取组内选定的 RadioButton
【发布时间】:2010-09-08 18:48:12
【问题描述】:

我有一个带有名为 priceClassGroupBox 的组框的 winforms 应用程序。在其中我动态地添加 RadioButtons,我给它一个 name,比如 radio1radio2radio3

我有两个问题:

  1. 我可以通过 name 自动选择给定的 RadioButton 而无需遍历每个控件吗?
  2. 我能否在不遍历每个控件的情况下获取所选 RadioButton 的名称

【问题讨论】:

    标签: c# winforms radio-button


    【解决方案1】:
    1. 是的,您可以致电Controls.Find

    例如

    RadioButton rdo = (RadioButton)priceClassGroupBox.Controls.Find("radio1", false);

    2 。不,您必须遍历并找到选定的单选按钮

    【讨论】:

      猜你喜欢
      • 2013-06-09
      • 2015-07-04
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-01
      • 1970-01-01
      相关资源
      最近更新 更多