foreach(Control c in Form.Controls)
{
    if (c is Button)
       //it's Button...
...
..
}

解决方案 »

  1.   

    我只会用C#:void DisplayAllControls(Control topctrl){
    foreach(Control ctrl in topctrl.Controls){
    Response.Write(ctrl.ID+" 是一个 "+ctrl.GetType().ToString()+"<br>");
    if(ctrl.HasControls())
    DisplayAllControls(ctrl);
    }
    }
      

  2.   

    这样用:void Page_Load(object src,EventArgs e){
    DisplayAllControls(this);
    }
      

  3.   

    foreach control ctrlLevel1 in this.controls
    {
       ...
       foreach control ctrlLevel2 in ctrlLevel1.controls
          { .....
          foreach ....
             {....
              }
           }
    }
    如果遍历更下一级的子控件,只要再重复上面的语句就可以了,VB的只要按照VB语法改一下就行了,我用C#,对VB不熟悉,只能以C#告诉你了
      

  4.   

    Dim c As Control
            For Each c In Me.Controls
                If (TypeOf (c) Is TextBox) Then
                    CType(c, TextBox).Text = ""
                    CType(c, TextBox).Style("TextAlign") = "HorizontalAlignment.right"
                End If
            Next