vb.net 如何在VB.Net的Panel中获取滚动条?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12507228/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 16:17:42  来源:igfitidea点击:

How to get scrollbar in Panel in VB.Net?

vb.netscrollbarpanel

提问by Brijesh Patel

I am developing a Windows Application in VB.Net. In that, there is one case where there is one form, and in that form there is a Panel, and within the Panel there is a rich text box.

我正在 VB.Net 中开发 Windows 应用程序。在这种情况下,有一种情况,只有一个表单,并且在该表单中有一个面板,并且面板内有一个富文本框。

So my requirement is to get a scrollbar in the Panel. So when the user does scroll on the panel, the rich text box can scroll accordingly like MS Office functionality..

所以我的要求是在面板中获得一个滚动条。因此,当用户在面板上滚动时,富文本框可以像 MS Office 功能一样相应地滚动。

Can any one give me an idea how to do it?

任何人都可以给我一个想法如何做到这一点?

采纳答案by SSS

Set the .Dock property to FILL and the .WordWrap property to FALSE for the richtextbox.

对于富文本框,将 .Dock 属性设置为 FILL,将 .WordWrap 属性设置为 FALSE。

Also set the Panel's .Dock property to FILL.

还将面板的 .Dock 属性设置为 FILL。

回答by Peladao

Set Panel.AutoScroll = Trueand scrollbars will automatically appear whenever any controls in the panel fall outside its boundaries.

Panel.AutoScroll = True只要面板中的任何控件超出其边界,设置和滚动条就会自动出现。

回答by LangitKTV

In order to use panel autoscroll property I do that:

为了使用面板自动滚动属性,我这样做:

panel.AutoScroll = true
panel.VerticalScroll.Visible = False or panel.HorizontalScroll.Visible = False

In order to know the dimensions of the scroolbars use

为了知道滚动条的尺寸使用

SystemInformation.HorizontalScrollBarHeight
SystemInformation.VerticalScrollBarWidth

So you can change the dimension of the panel when the scroolbar is shown.

因此,您可以在显示滚动条时更改面板的尺寸。