Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to Empty all the Textboxes of your Windows Form

Author: DevASP
Download Source Code : 318_TextBox.zip

This article is how your can empty all the text fields on your form or can assign a same value to all the text fields. You can also implement this to any of your control on your form.

  • Steps you will do.
  • Start visual studio and create new window application.
  • Set the following properties of your form

 

Name = frmMain

Text = TextBoxes

Borderstyle = FixedSingle

Maximize = False

  • Now drop four textbox control on your form and set the properties as below.

First textbox.

Name = tbtext

Text = “”

 

Second textbox.

Name = tb1

Text = “”

 

Third textbox.

Name = tb2

Text = “”

 

Fourth textbox.

Name = tb3

Text = “”

 

  • Drop two button controls on your form and set their following properties.

First button

Name = btAdd

Text = Add text to fields

 

Second button

Name = btClear

Text = Clear all text fields

 

  • Open your code window and write the following code in the click event of btAdd.

 

Dim obj As New Control

For Each obj In Me.Controls

If TypeOf obj Is TextBox Then

If Not obj.Name = "tbtext" Then

obj.Text = tbtext.Text

End If

End If

Next

  • Write the following code in the click event of btClear.

 

Dim obj As New Control

For Each obj In Me.Controls

If TypeOf obj Is TextBox Then

If Not obj.Name = "tbtext" Then

obj.Text = ""

End If

End If

Next

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to Create a Dynamic Array of Controls in Visual Basic.Net(VB.Net)

Disclaimer - Privacy
© 2002-2017 DevASP.net