因为在panel所以只可能有一个被选中? 怎么得到? 他们的text是相同的  索引和name不同 怎么得到?最简单最好?

解决方案 »

  1.   

                foreach (Control c in this.Controls)
                {
                    if (c is System.Windows.Forms.RadioButton)
                    {
                        if (((RadioButton)c).Checked)
                        {
                            MessageBox.Show(c.Name+"被选中");
                        }
                    }
                }
      

  2.   

    以上方法,循环遍历窗体内所有的控件,再进行判断看是否为RadioButton控件,最后判断是否被中.不过少加了句代码.用下面这个:            foreach (Control c in this.Controls)
                {
                    if (c is System.Windows.Forms.RadioButton)
                    {
                        if (((RadioButton)c).Checked)
                        {
                            MessageBox.Show(c.Name + "被选中");
                            break;
                        }
                    }
                }
      

  3.   

    用foreach循环一下Panel的子控件,如果是RadioButton,看看它是不是选中的就行了foreach (Control ctrl in panel.Controls)
    {
    if (ctrl is RadioButton)
    {
    RadioButton rb = ctrl as RadioButton;
    if (rb.选中)
    {
    return rb;
    }
    }
    }如果所有的RadioButton选中事件都由一个方法来处理的,也可以把sender参数记下来,它就是选中的。
      

  4.   

      For Each s As RadioButton In Controls
                If s.Checked Then
                    ‘.....
                End If
            Next
      

  5.   

    遍历,再判断是不是被选中... 
    foreach (System.Windows.Forms.Control control in this.Controls)
     {
       if (control is System.Windows.Forms.RadioButton)
       {
        System.Windows.Forms.RadioButton rb = (System.Windows.Forms.RadioButton)control;
        if (rb.Checked == true)
            {
                MessageBox.Show(rb.Name.ToString()+" has been checked.");
            }
       }
    }