VB.Net - 如何滚动 GroupBox
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18104806/
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
VB.Net - How to scroll through GroupBox
提问by Nick L
Please excuse my lack of familiarity with vb.net. Just got thrown on a project with no vb.net experience.
请原谅我对 vb.net 的不熟悉。刚刚被扔到一个没有 vb.net 经验的项目上。
I have to add some things to an application that was written by somebody who is no longer in the picture. I have to add more textboxes into a groupbox and when I do that it exceeds the size of the form. How can I make it so that I can scroll through the groupbox?
我必须向已不在图片中的某个人编写的应用程序添加一些内容。我必须将更多文本框添加到 groupbox 中,当我这样做时,它超出了表单的大小。我怎样才能让它滚动浏览分组框?
回答by Ryan McDonough
GroupBox, as it doesn't derive from ScrollableControl, so itself can't have scrolling functionality.
GroupBox,因为它不是从 ScrollableControl 派生的,所以它本身不能有滚动功能。
So...
所以...
Place the GroupBox inside a panel, and set the panel AutoScrollto true.
将 GroupBox 放在面板内,并将面板设置AutoScroll为true。
Guides:
指南:
Setting properties (of anything)
Moving content is just simply selecting all the elements you want to move, and click and drag them into the new place.
移动内容只是简单地选择要移动的所有元素,然后单击并将它们拖动到新位置。
回答by davidsbro
You could set the AutoSizeproperty of the groupbox to true, and then set the AutoScrollof the form to trueas well. This should resize the groupbox so that everything in it is visible, and then the form will have a scrollbar. If you don't want to make your form have a scrollbar for some reason, then you could use a panel and set it's AutoScrollto True so that just the panel has a scrollbar.
您可以将AutoSizegroupbox的属性设置为true,然后将AutoScroll表单的 也设置true为 。这应该调整 groupbox 的大小,使其中的所有内容都可见,然后表单将有一个滚动条。如果由于某种原因您不想让表单具有滚动条,那么您可以使用面板并将其设置AutoScroll为 True 以便只有面板有滚动条。
回答by SysDragon
Add a Panelwith no border inside the GroupBoxto group your controls (put the controls inside). Then:
Panel在里面添加一个没有边框GroupBox的控件来分组你的控件(把控件放在里面)。然后:
Panel1.ScrollBars = ScrollBars.Vertical
Or even ScrollBars.Auto.
甚至ScrollBars.Auto。
回答by Derek Meyer
GroupBox doesnt have scrolling functionality itself. Most likely most simple solution here is to just put a Panel inside the groupbox and add the textboxes to the panel instead.
GroupBox 本身没有滚动功能。这里最可能最简单的解决方案是将一个面板放在组框内,然后将文本框添加到面板中。

