Function to Clear all controls from windows form

  • Private Sub clearInformation(ByVal p As Control)

    For Each ctrl As Control In p.Controls
    If TypeOf ctrl Is Panel Or TypeOf ctrl Is GroupBox Or TypeOf ctrl Is TabControl Then


    ElseIf TypeOf ctrl Is TextBox Then
    DirectCast(ctrl, TextBox).Text = String.Empty
    ElseIf TypeOf ctrl Is ComboBox Then

    Dim combo As ComboBox = TryCast(ctrl, ComboBox)

    If combo.DropDownStyle = ComboBoxStyle.DropDownList Then
    combo.SelectedIndex = 0

    combo.Text = String.Empty

    End If
    End If


    End Sub

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week