简体   繁体   中英

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?

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 .

did you add the groupBox1 into the main Control?

this.Controls.Add(groupBox1);

Also try setting Visible = true on groupBox 2 as well

I think you just need to add a groupbox.Location. Then it will appear.

var groupBox = new GroupBox();
groupBox1.Controls.Add(groupBox);
groupBox.Location = new Point(somex,somey);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM