为什么groupBox4不可见? [英] why is groupBox4 not visible?

查看:64
本文介绍了为什么groupBox4不可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的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

推荐答案

是的,这是一个原因。您堆叠了groupBoxes,即groupBox4包含在groupBox3中。当您将groupBox3.Visible设置为False时,groupBox3的所有内容都是不可见的。

您应该将每个groupBox控件的Parent属性设置为您的Form。您可以在代码中执行此操作:

Yes, that is a reason. You stacked your groupBoxes, and i.e. groupBox4 is contained in groupBox3. When you set groupBox3.Visible to False, all content of groupBox3 is being invisible.
You should set Parent property of each groupBox control to your Form. You can do this in your code:
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不可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆