Reset all Text in TextBox on form by using simple code.
Using this simple code we can reset all TextBox on form.
In this code i use For Each Loop for select each TextBox on Form.
I declare one variable as control then i use loop and i also use TypeOf Operator which are used to define type of variable.
TypeOf Operator.
1) Place TexBox on Form.
2) Place Two Button (Reset and Close).
Using this simple code we can reset all TextBox on form.
In this code i use For Each Loop for select each TextBox on Form.
I declare one variable as control then i use loop and i also use TypeOf Operator which are used to define type of variable.
TypeOf Operator.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim contrl As Control
For Each contrl In Me.Controls
If TypeOf contrl Is TextBox Then
contrl.Text = ""
End If
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
Source Code.
Hello There,
Very nice code but i don't know vb
so any one can convert this into c#
Thanks and Regards,
Shourya V. sengar