private void button1_Click(object sender, System.EventArgs e)
{
this.FindCtrl(this);
}
private void FindCtrl( Control control )
{
foreach( Control c in control.Controls )
{
//if(c is TextBox)
//{
// c.Text = "";
//}
                  //........这里加上你的控制代码
if (c.Controls != null)
{
FindCtrl( c );
}
}
}

解决方案 »

  1.   

    foreach(System.Windows.Forms.Control sControl in thisControls)
    {
    {
    switch(sControl.GetType().Name)
    {
    case "TextBox":
    break;
    case "ComboBox":
    break;
    case "Num":
    break;
    }
    }
    }
      

  2.   

    使用遍历,一次检查窗体中的数据
    http://blog.csdn.net/gong_hui2000/archive/2004/12/09/CheckFormcontrols.aspx
      

  3.   

    例如:
    public static void ChangeControl(object sender,bool bEnable,bool bClear)
    {
    try
    {
    Control s=(Control)sender;
    foreach(Control f in s.Controls)
    {
    if(f.Controls.Count>0 )
    {
    //如果当前的控件存在子控件,则此步递归
    ChangeControl(f,bEnable,bClear);
    }
    if(f.Tag ==null)continue;
    f.Enabled =bEnable;
    if(f.Tag.ToString().Substring(0,1)=="2")
    {
    TextBox ct=(TextBox)f;
    if(bClear)ct.Text ="";
    if(f.Tag.ToString().Length ==1)
    {
    if(bEnable)ct.BackColor =Color.Lavender;
    else ct.BackColor =Color.Empty;
    }
    else
    ct.Enabled =false;
    }
    else if(f.Tag.ToString()=="3")
    {
    //........
    }
    catch(Exception ee)
    {
    MessageBox.Show(ee.Message);
    }
    }
    }
    }
      

  4.   

    private void FindButton(Control c)
    {
    if(c is Button)
    {
    MessageBox.Show("Button!");
    }
    if (c.Controls != null)
    {
    foreach(Control x in c.Controls)
    {
    FindButton(x);
    }
    }
    }在窗体里面调用
    this.FindButton(this);
      

  5.   

    第归Controls集合。
    特别注意组合控件的处理,例如:
    UserControl
    TabControl