Friday, January 22, 2010

How to clear all the textbox/groupbox on single click

public void ClearTextBox(Form f)
{
for (int i = 0; i < f.Controls.Count; i++)
{
if (f.Controls[i] is TextBox)
{
f.Controls[i].Text = "";
}
else if (f.Controls[i] is GroupBox)
{
for (int j = 0; j < f.Controls[i].Controls.Count; j++)
{
if (f.Controls[i].Controls[j] is TextBox)
{
f.Controls[i].Controls[j].Text = "";
}
}
}
}
}
//How to call this function(Into the Submit Button)
Make a object from the Program.cs file.
object.ClearTextBox(this);
//After submit query