我想可以用下面的方法试试:
for(int i=0;i<this.Controls.Count;i++)
{
   object obj=this.Controls[i];
   if(obj is Button) MessageBox.Show("Button");
}

解决方案 »

  1.   

    ilovecs(csharper) :
    大哥这不是遍历是什么?哈哈哈
      

  2.   

    when you add a control, also save the control object in a hashtableclass YourForm : Form
    {
       Hashtable ht = new Hashtable();
       Button bt;
       public YourForm()
       {
            bt = new Button();
            bt.Text = "Whatever";
            Controls.Add(bt);
            ht["Whatver"] = bt;
       }...
    }to get the control, use ht["Whatver"];
      

  3.   

    http://www.csdn.net/expert/topic/1083/1083153.xml?temp=.9578668
      

  4.   

    好像都没有合适的答案.
      FindControl("id")是web方式下查找控件的方法http://www.csdn.net/expert/topic/1083/1083153.xml?temp=.9578668
    适合于使用类的情况
    我得控件有很多控件不是程序生成的,看来saucer(思归)的方法也不行
      

  5.   

    实在不行我就只好用那个嘴笨的方法了,遍历.可是Controls只能得到直接子控件.不会还要我用递归吧,有没有大侠有什么好方法?加100分
      

  6.   

    --我得控件有很多控件不是程序生成的
    --效率(编程时)比用遍历差多了吧
    在恰当的时候遍历,在遍历的时候构建Hash表,之后就通过访问Hash获得