Clear Multiple TextBoxes in C#

Clear Multiple TextBoxes in C#

If you are a beginner in Programming Languages and you’re using, this tutorial will help you minimize your codes and lessen your work. This procedure is to clear all the data in the TextBoxes in a certain Form, for example, when you create a “Registration” Form.


To start with:

Open Microsoft Visual Studio and create new Windows Form Application. Then do the following design of a Form as shown below.


After that, go to the Solution Explorer, double click the “View Code”  to display the code editor.


Then, create a method for clearing the text in the Textboxes.

 private void clearTxt(Control container)
 //'for each txt as control in this(object).control
 foreach (Control txt in container.Controls)
 //conditioning the txt as control by getting it's type.
 //the type of txt as control must be textbox.
 if (txt is TextBox)
 //if the object(textbox) is present. The result is, the textbox will be cleared.
 txt.Text = "";

 catch(Exception ex)

Go back to the design view, double click the “Clear” button and do the following codes for calling the method of clearing text.

 private void button1_Click(object sender, EventArgs e)
 //call a method for clearing all text in the textbox



For all students who need programmer for your thesis system or anyone who needs a sourcecode in any programming languages. You can contact me @ :

Email – [email protected]
Mobile No. – 09305235027 – tnt

Project Name : Clear Multiple TextBoxes in C#.Net
Project Platform :C#
Programming Language Used:C# Programming Language
Developer Name
IDE Tool (Recommended):Visual Studio 2019
Project Type :Desktop Application
Upload Date and Time:June 13, 2016- 7:26 am

4 thoughts on “Clear Multiple TextBoxes in C#”

  1. You really make it seem really easy with your presentation but I find this matter to be really one thing which I feel I might by no means understand. It kind of feels too complex and extremely broad for me. I am looking forward for your next submit, I’ll try to get the hold of it!

Leave a Comment