public void Clean(Form form)
{
for (int i = 0; i < form.Controls.Count; i++)
{
//清空TextBox值
if (Controls[i].GetType() == typeof(TextBox))
{
((TextBox)Controls[i]).Text = "";
}
//清空label值
if (Controls[i].GetType() == typeof(Label))
{
((Label)Controls[i]).Text = "";
}
//其余控件以此类推
//清空所有控件的值
Controls[i].Text = "";
}
}
//调用方法.
Clean(this.FindForm());
------------------------------------------------------------------
//将所用字段放在一个groupBox中,
foreach(Control c in this.groupBox)
{
if(c is TextBox || c is lable || c is CombBox)
{
c.Text="";
}
}