写一个函数,传递该窗体当参数。在代码里使用 controls.find()来进行处理即可。

解决方案 »

  1.   

    基类窗口中写入
            public List<Control> GetAllContorls()
            {
                List<Control> l = new List<Control>();            GetContorls(this, l);
                return l;
            }        private void GetContorls(Control cs, List<Control> list)
            {
              //  foreach (Control c in cs.Controls)
                foreach (Control c in GetControls(cs))
                {                list.Add(c);
                    if (c.HasChildren)
                    {
                        GetContorls(c, list);
                    }
                }
            }通过上面两个方法,取得所有控件
    然后判断每个控件是不是Button
    private void SetButtonVisible(, List<Control> list)
    {
    foreach (control  c in list)
    {
    if (c is Button)
    {
    (c as Button).Visible = false;}}
    }
      

  2.   

    写个方法,传control的集合进来
    循环设置enable=false
      

  3.   

    Visible = false
    上面那个写错了,那个是设置不可用