为什么groupBox4不可见?

编程入门 行业动态 更新时间:2024-10-28 09:28:24
本文介绍了为什么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不可见?

本文发布于:2023-11-15 05:06:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1591404.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!