Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27351

Looping thru controls on a form?

$
0
0
I was wondering if there is a way to loop thru all the controls on a form that will include all controls within container controls within the form. In other words, I handle such code like this:

Code:

      For Each ctl1 As Control In frm.Controls
          If TypeOf(ctl1) Is GroupBox Then
                For Each ctl2 In ctl1.Controls
                    ...change property values
                Next
          ElseIf TypeOf(ctl1) Is TabControl Then         
                For Each ctl2 In ctl1.Controls
                    ...change property values
                Next
          End If
      Next

Are the inner For Loops required in order to account for every control on a form or is there a better way to do this?

Thanks,

Viewing all articles
Browse latest Browse all 27351

Trending Articles