foreach(Control ctl in Controls)
{
...}

解决方案 »

  1.   

    foreach(Control ctl in Page.Controls[1].Controls )
    {
    ...
    }
      

  2.   

    那么怎么才能知道他是TextBox 还是Combox
      

  3.   

    ...
    {Combox combox = (ctl as CheckBox)
      { 
          if (combox != null)
          {
           //To do: write code here
         }
    }
    ...
      

  4.   

    在vb中:
    foreach ctl in me.Controls
       if typeof ctl is Combox then
       end if
       if typeof Ctl is TextBox then
       end if
    next===========
    在C#中没有这么方便的判断方法吗?
      

  5.   

    if(typeof(TextBox).IsInstanceOfType(control))
    {
    }
      

  6.   

    例子
    foreach(Control c in this.Controls)
    {
        switch(c.GetType().Name.ToUpper())
        {
          case "COMBOBOX":
          default:
        }
    }
      

  7.   

    if(control is ComboBox)
    {
    }
    else
    {
    //control is not a ComboBox or control==null
    }
      

  8.   

    foreach(Control ctl in Controls)
    {
    if(ctl is TextBox) //or if(ctl.GetType()==(new TextBox()).GetType)
    ..
    //其它类似}