Mohamed Ahmed Mohamed Ahmed - 3 years ago 238
C# Question

Preventing a CheckBox on the top of a GroupBox to be a child control?

I want to set a CheckBox on the top of a GroupBox like in this picture to enable/ disable the groupBox:

enter image description here

but in this position, the checkBox is contained within the GroupBox child controls, so it is disabled once I disable the GroupBox..

So Is there a way to keep it in this location , but excluding it from the groupBox controls?
I tried, Bring to front, but doesn't help!

Answer Source

I'm assuming you're trying to do this via the designer? If so, then as soon as you move the CheckBox over the GroupBox, the designer will automatically assume (not unreasonably), that you want the CheckBox to be contained by the GroupBox.

To get around this, drag the CheckBox outside of the GroupBox, right-click on the CheckBox and select "Bring to Front" so that it will be drawn on top, and then edit the CheckBox's position manually via the Location property in the Properties window.

Don't modify the CheckBox's position via the mouse afterwards or the designer will put it back into the GroupBox and you'll have to reposition manually again.

Alternatively you can do this programmatically as seen here (credit o_O).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download