Click here to Skip to main content
15,907,396 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

My query is I'm developing a Desk Top application in VB.Net. After entry in more than 50 Text boxes,combo box, rich text box & so on I want that clear all the textbox as empry instead of putting the command of textbox.text=" ". Bcoz it a Lengthy process.

Pl guide me how to clear the text of all the textbox with a single command.

Jatinder gupta.
Posted

Hello!
all the controls derived from Control Class and any control has the property text.
this code for reset all controls in form to empty text
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
    For Each ctrl As Control In Me.Controls
        ctrl.Text = ""
    Next
End Sub


you can use String.Empty instead of ""
 
Share this answer
 
Comments
Jatinder Gupta 22-Aug-10 6:23am    
Thanks.Problem has been solved with control...
Have a look at this: Reset all controls on form (Windows forms – C#)[^]

It's in C#, but you will get an idea of possible easy way.
 
Share this answer
 
Comments
koolprasad2003 21-Aug-10 3:46am    
Reason for my vote of 3
good link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900