|
|
|
Here is the small code snippet to clear most of all controls on your form. This code also take care of containers like group box, panel ... etc. |
Click here to copy the following block | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ClearControls(Me.Controls) End Sub
Private Sub ClearControls(ByVal cControls As Windows.Forms.Control.ControlCollection) Dim c As Control
For Each c In cControls
If TypeOf c Is TextBox Then CType(c, TextBox).Text = "" ElseIf TypeOf c Is ComboBox Then CType(c, ComboBox).Items.Clear() ElseIf TypeOf c Is ListView Then CType(c, ListView).Items.Clear() ElseIf TypeOf c Is TreeView Then CType(c, TreeView).Nodes.Clear() ElseIf TypeOf c Is CheckBox Then CType(c, CheckBox).Checked = False ElseIf TypeOf c Is ListBox Then CType(c, ListBox).Items.Clear() End If
If c.Controls.Count > 0 Then ClearControls(c.Controls) Next End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|