在 VB.net 中隐藏控件组
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14229520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide Group of controls in VB.net
提问by Thanzeem
In my VB.NET project form with employee details have fourteen label boxes, five text boxes, four masked text boxes, two combo boxes, two radio buttons, one rich text boxes and two buttons. I want to hide these items when form is load. I try with
在我的带有员工详细信息的 VB.NET 项目表单中,有十四个标签框、五个文本框、四个蒙版文本框、两个组合框、两个单选按钮、一个富文本框和两个按钮。我想在加载表单时隐藏这些项目。我试试
.Visible = False
method. But it is a long code.. How i hide these items in a simple code?
方法。但它是一个长代码.. 我如何用一个简单的代码隐藏这些项目?
采纳答案by patrick choi
put those controls in a GroupBox2 and set its visible property to false.
将这些控件放在 GroupBox2 中并将其可见属性设置为 false。


When your application runs, GroupBox is not visible so i use a button captioned "Show GroupBox2" so When i clicked the button, GroupBox2 will be visible:
当您的应用程序运行时,GroupBox 不可见,因此我使用标题为“Show GroupBox2”的按钮,因此当我单击该按钮时,GroupBox2 将可见:


Source code for making the GroupBox Visible
使 GroupBox 可见的源代码
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GroupBox2.Visible = True
End Sub
回答by Gopalakrishnan SA
Use a Panelwhich contains all those controls (label,txtbox,combobox etc.,) and set the .visible property on the panel as false. In this case , you do not have to set the .visible for each and every control.
使用Panel包含所有这些控件(label、txtbox、combobox 等)的 a 并将面板上的 .visible 属性设置为 false。在这种情况下,您不必为每个控件设置 .visible。
回答by slggamer
you could put them to a panel, then you only need set the visible of panel
你可以把它们放在一个面板上,然后你只需要设置面板的可见性

