Search code examples
c#.netwinformswindows-forms-designergroupbox

groupbox inside groupbox in c#


I have MSVC 2010 and I need to put a groupbox inside a groupbox. It does not work when I tried to use GUI editor, and it does not work when I use:

groupbox1.Controls.Add(groupbox2);
groupbox.Visible = true;

If I use the code above the second box just does not display. If I use the GUI editor the second box just does not show inside the first one.

Can anybody help please?


Solution

  • Change child control location:

    groupBox1.Controls.Add(groupBox2);
    groupBox2.Location = new Point(10, 10);
    

    from Control.Location (MSDN):

    Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.