问题描述
我的Form1中有以下代码:
Hi,
I have the following code in my Form1:
private void gen_keys_button_Click(object sender, EventArgs e)
{
groupBox4.Visible = true; //show gen L & R keys group box
groupBox1.Visible = false; //hide gen L & R keys group box
groupBox2.Visible = false; //hide gen L & R keys group box
groupBox3.Visible = false; //hide gen L & R keys group box
}
执行时,groupBox1,2 ,3变得隐形& groupBox4也是如此。但它不应该。
为什么? GroupBOX1& 4大致相同的大小&几乎相互重叠。这可能是原因吗?
感谢您提前的帮助。
问候
Kishor Mistry
When executed, groupBox1,2,3 become invisible & so does groupBox4. But it is NOT supposed to.
Why? GroupBOX1 & 4 are roughly the same size & almost overlap one another. Could this be the reason?
Thanks for your help in advance.
Regards
Kishor Mistry
推荐答案
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
groupBox1.Parent = groupBox2.Parent = groupBox3.Parent = groupBox4.Parent = this;
}
此外,您可以使用代码定位控件。
Visual Studio提供了名为Document Outline的窗口(View-> Other windows-> Document outline)。它会向您显示表单的控件层次结构,您可以通过拖放操作在此处对其进行排列。下降。
我希望我帮助过你:)
Also, you can position controls with your code.
Visual Studio offers window called Document Outline (View->Other windows->Document outline). It shows you your form's control hierarchy and you can arrange them here by drag & drop.
I hope I helped you :)
这篇关于为什么groupBox4不可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!