Skip to content

Instantly share code, notes, and snippets.

@rahuldass
Created May 13, 2015 10:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahuldass/028d2657ded7266c7893 to your computer and use it in GitHub Desktop.
Save rahuldass/028d2657ded7266c7893 to your computer and use it in GitHub Desktop.
Clear all Textboxes in C#

###Clear all Textboxes

Clear all Textboxes in C#

Button Click

private void clearButton_Click(object sender, EventArgs e)
        {
            ClearAllText(this);
        }

Function

void ClearAllText(Control con)
        {
            foreach (Control c in con.Controls)
            {
                if (c is TextBox)
                    ((TextBox)c).Clear();
                else
                    ClearAllText(c);
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment