Question Cycle textboxes within groupbox

rvercesi

Member
Joined
Oct 16, 2008
Messages
10
Programming Experience
5-10
Hi there

Anyone knows how to cycle all textboxes within a determined groupbox?

I can figure out how to cycle all controls in the form but can't get past that point.

Regards,

RVercesi
 
Last edited:
Found the answer my self...
Just needed to search a bit more

VB.NET:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each tp As TabPage In tabs.TabPages
            ClearFields(tp)
        Next
    End Sub

    Private Sub ClearFields(ByVal cntr As Control)
        For Each ctl As Control In cntr.Controls
            If TypeOf ctl Is TextBox Then
                ctl.Text = ""
            ElseIf TypeOf ctl Is CheckBox Then
                CType(ctl, CheckBox).Checked = False
            ElseIf TypeOf ctl Is ComboBox Then
                CType(ctl, ComboBox).SelectedIndex = -1
            ElseIf ctl.HasChildren Then
                ClearFields(ctl) ' <--------------------------------- Recurse into control with children
            End If
        Next
    End Sub

Credit to: Idle Mind
VB.net Clear All TextBoxes in each GroupBox on each TabPage : clear, all, groupbox
 
Back
Top