简体   繁体   English

C#中groupbox内的groupbox

[英]groupbox inside groupbox in c#

I have MSVC 2010 and I need to put a groupbox inside a groupbox. 我有MSVC 2010,需要将一个groupbox放在一个groupbox中。 It does not work when I tried to use GUI editor, and it does not work when I use: 当我尝试使用GUI编辑器时,它不起作用,而当我使用时,它不起作用:

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. 如果使用GUI编辑器,则第二个框不会显示在第一个框中。

Can anybody help please? 有人可以帮忙吗?

Change child control location: 更改子控件的位置:

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

from Control.Location (MSDN): 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? 您是否将groupBox1添加到主控件中?

this.Controls.Add(groupBox1);

Also try setting Visible = true on groupBox 2 as well 也尝试在groupBox 2上设置Visible = true

I think you just need to add a groupbox.Location. 我认为您只需要添加一个groupbox.Location。 Then it will appear. 然后它将出现。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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