“如果x是否是组合框类型”,即if(x.GetType()==组合框类型),这个语句如何写?

解决方案 »

  1.   

    if( x is 组合框类型)
    {
    }
      

  2.   

    if (x is System.Windows.Forms.ComboBox)
      

  3.   

    如果只是判断,用上面三位的方法就可以了,如果还要使用转换为组合框后的值,最好这样子:
    组合框 group = x as 组合框;
    if(group != null)
    {
      group.xx
    }
      

  4.   

     foreach (Control c in Controls) 
                {
                    if (c is GroupBox) 
                    {///
                        MessageBox.Show(c.Text );
                    }            }
    我觉得判断嘛,就应该循环遍历每一个控件;然后用c.操作起来应该会好点!!