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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.