Groupbox Control ?

Jess31
Jess31 used Ask the Experts™
on
How can I have a Checkbox that appears inside a Groupbox but it should not be bound to the Groupbox, so if I set the Groupbox to Enable=False the CheckBox will still be Enabled?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dim pt = Me.PointToClient(GroupBox1.PointToScreen(CheckBox1.Location))
CheckBox1.Parent = Me
CheckBox1.Location = pt
CheckBox1.BringToFront()

Open in new window

PS. For any control:
Private Sub UnBox(c As Control)
    If c.Parent Is Me Then Return
    Dim pt = Me.PointToClient(c.Parent.PointToScreen(c.Location))
    c.Parent = Me
    c.Location = pt
    c.BringToFront()
End Sub

Open in new window

Using: UnBox(CheckBox1).
Another option - do not disable groupbox but disable control(s) instead:
Private Sub EnableBoxControls(box As GroupBox, ParamArray enabledControls() As Control)
    For Each c As Control In GroupBox1.Controls
        c.Enabled = enabledControls.Contains(c)
    Next
End Sub

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial