ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

Clear Multiple TextBoxes in C#.Net

clearMultiTextboxCSharpPIIf you are a beginner in Programming Languages and you’re using C#.net, 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 2008 and create new Windows Form Application. Then do the following design of a Form as shown below.

clearMultiTextboxCSharpFig.1

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

clearMultiTextboxCSharpFig.2

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

 private void clearTxt(Control container)
 {
 try
 {
 //'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)
 {
 MessageBox.Show(ex.Message);
 }
 }

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
 clearTxt(this);
 }

 

Output:

clearMultiTextboxCSharpPI

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 – jannopalacios@gmail.com
Mobile No. – 09305235027 – tnt

Facebook Comments

Check Your Domain Ranking

4 Comments

Add a Comment
  1. De esta manera, cuando estornudaba, tosia corria mis musculos del suelo pelvico no tenian la suficiente tonicidad para retener de manera inconsciente la orina en la vejiga y evitar que tuviera escapes.

  2. 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!

  3. It is not my first time to pay a visit this site, i am visiting this website dailly and take nice information from here all the time.

  4. La ola de liberacion de los sesenta recorrio America del Sur y llego hasta ese rincon al final del continente donde vivia.

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!