我在button2做了个清空所有信息 怎样才能清空前面填写信息,如果要一个一个的Close 那不实际太多了,文本,标签什么都有!  请教下大哥,我现在写不出来,怎么样才能实现这个功能呢!!!!!小弟刚刚注册, 不知道分是怎么来的! (等有了绝对少不了)
告诉下小弟,小弟感激不尽!!!

解决方案 »

  1.   

    foreach(Control con in this.Controls)
    {
     con.Text = "";
    }
      

  2.   

    foreach(Control ctl in this.Controls)
    {
        //如果是文本框则清空
         if (ctl.GetType().Name=="TextBox")
         {
         ctl.Text = "";
         }
    }
      

  3.   

    foreach (Control c in this.Controls)
            {
                if (c is TextBox || c is ComboBox)
                {
                    c.Text = string.Empty;
                }
            }