0

hi,
i have 12 groupbox in each tabcontrol page. And i want to keep all groupbox in same location of same size overlapping each other. I want to make one function and apply to all groupbox. So that my code wouldnot be lengthy. But i didnot get idea to do so. so provide me some code and hints sir. would be greatfull.

3
Contributors
2
Replies
16
Views
4 Years
Discussion Span
Last Post by ShahanDev
0

You can iterate through all controls, or in this example, all controls of a given type.

For Each ctrl As GroupBox In TabControl1.TabPages(0).Controls.OfType(Of GroupBox)()
    MyCustomSub(ctrl)
Next

Private Sub MyCustomSub(ctrl As GroupBox)
    .
    .
    .
End Sub

Edited by Reverend Jim

0

Try using the below sample code:

        ' iterate on all pages of tab control
        For Each page As TabPage In TabControl1.TabPages 

            ' picked GroupBox controls only in a separate variable 
            ' to aviod evaluation each time during loop
            Dim grpBoxes() As GroupBox = page.Controls.OfType(Of GroupBox)() 

            For Each grpBox As GroupBox In grpBoxes  ' iterate on all group box controls
                With grpBox   ' I would prefer to use WITH statement here

                    'Set parameter(s) here
                    .SetBounds(50, 50, 100, 100)

                End With
            Next
        Next

Please have a look at the details also.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.