Try a panel with borders set?
Or...
Private Sub DrawBorder(ByVal Controls As Control())
Dim x1 As Integer = Integer.MaxValue
Dim x2 As Integer = Integer.MinValue
Dim y1 As Integer = Integer.MaxValue
Dim y2 As Integer = Integer.MinValue
Dim graph As Graphics = Me.CreateGraphics()
Dim pen As Pen
Dim rect As Rectangle
For Each Control As Control In Controls
x1 = Min(x1, Control.Left)
x2 = Max(x2, Control.Left + Control.Width)
y1 = Min(y1, Control.Top)
y2 = Max(y2, Control.Top + Control.Height)
Next
' Draw the borders around the controls.
pen = New Pen(Color.Blue, 1)
rect = New Rectangle(x1 - 4, y1 - 4, (x2 - x1) + 4, (y2 - y1) + 4)
graph.DrawRectangle(pen, rect)
End Sub
Private Function Max(ByVal Num1 As Integer, ByVal Num2 As Integer) As Integer
Return IIf(Num1 > Num2, Num1, Num2)
End Function
Private Function Min(ByVal Num1 As Integer, ByVal Num2 As Integer) As Integer
Return IIf(Num1 < Num2, Num1, Num2)
End Function
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim controls As Control() = New Control() { _
Checkbox1, Checkbox2, Checkbox3, Checkbox4, Checkbox5, Checkbox6 _
}
DrawBorder(controls)
End Sub
"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
Hi just wondering if there is an easy way to a box around a bunch of controls
like -----------------------------------------------------
| control1 control2 control3 |
| |
----------------------------------------------------
thanks,
--
Paul G
Software engineer.