方法1:一个是把这20个放在一个group框里。这个就互斥了。再做一个变量来识记一下。
方法2:放到arraylist之类的容器里。到时从头到尾判断一下。

解决方案 »

  1.   

    你问的问题应该有两个方面:
    1.找出20个RadioButton中某个特定的RadioButton(如RadioButton1)的Checked属性是否为true,则直接判断即可:
          if RadioButton1.Checked==true 
             { ...}
    2.找出20个RadioButton中Checked属性为true的是哪一个?则依次判断每一个RadioButton的Checked属性即可(如上),或构造一个包含所有RadioButton对象的集合,任何使用foreach 循环。
      

  2.   

    foreach(System.Windows.Forms.Control obj in this.Controls)
    {
    if(obj.GetType().Name.ToString()=="RadioButton")
    {
    //obj转换成RadioButton,再做判断
    }

    }
      

  3.   


    private string GetChkName(){
       foreach(control ctrl in frm.Controls)
       {
          if(ctrl is RadioButton)
          {
             RadioButton rt=ctrl as RadioButton;
             if(rt.Checked)
                return rt.Name;
          }
       }
       return "";
    }
      

  4.   

    楼上非常对,得写一个Controls的控件集合,用foreach遍历
      

  5.   

    foreach(Control cmicCtl in this.Controls)
    {
    if(cmicCtl.GetType()==typeof(RadioButton))
    {
    RadioButton cmicRdo=(RadioButton)cmicCtl;
    if(cmicRdo.Checked==true)
    {
    strCode=cmicRdo.Tag.ToString();//cmicRdo你要的控件
    strLocation=cmicRdo.Text;
    break;
    }
    }
    }
      

  6.   

    foreach(Control cmicCtl in this.Controls)
    {
    if(cmicCtl.GetType()==typeof(RadioButton))
    {
    RadioButton cmicRdo=(RadioButton)cmicCtl;
    if(cmicRdo.Checked==true)
    {
    strCode=cmicRdo.Tag.ToString();//cmicRdo你要的控件
    strLocation=cmicRdo.Text;
    break;
    }
    }
    }