Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

ResetControls - Reset the value for the input array of controls

Total Hit ( 2753)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
' Resets the value for the input array of controls, and thier child controls
' Example:
'  - reset all the controls on the form: ResetControls(Me)
'  - reset specific controls: ResetControls(TextBox1, CheckBox1, GroupBox1)

Sub ResetControls(ByVal ParamArray ctls() As Control)
  ' clear input control
  Dim ctl As Control
  For Each ctl In ctls
    If TypeOf (ctl) Is TextBoxBase Then
      CType(ctl, TextBoxBase).Text = ""
    ElseIf TypeOf (ctl) Is CheckBox Then
      CType(ctl, CheckBox).Checked = False
    ElseIf TypeOf (ctl) Is RadioButton Then
      CType(ctl, RadioButton).Checked = False
    ElseIf TypeOf (ctl) Is ListView Then
      CType(ctl, ListView).Items.Clear()
    ElseIf TypeOf (ctl) Is TreeView Then
      CType(ctl, TreeView).Nodes.Clear()
    ElseIf TypeOf (ctl) Is ListBox Then
      CType(ctl, ListBox).Items.Clear()
    ElseIf TypeOf (ctl) Is ComboBox Then
      CType(ctl, ComboBox).Items.Clear()
      CType(ctl, ComboBox).Text = ""
      ' Note: to add support for more controls just add more ElseIf blocks
    End If
    ' clear all child controls, if any
    Dim c As Control
    For Each c In ctl.Controls
      ResetControls(c)
    Next
  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 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.