C# 如何在win窗体中设置垂直滚动条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2227610/
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
how to set vertical scroll bar in win form
提问by nimi
I am very new to win form. I want to develop a form which has a height of around 992*1403. i tried to give the size of the win form as 992*1403, but its taking only 992*876. i am setting an image of size 992*1403 as the background. i need to put a vertical scroll bar. i put that scroll bar but i dnt know how to write the code when the user scrolls that scroll bar.
我对胜利形式很陌生。我想开发一个高度约为 992*1403 的表单。我试图将获胜形式的大小设置为 992*1403,但它仅占用 992*876。我正在设置大小为 992*1403 的图像作为背景。我需要放置一个垂直滚动条。我放了那个滚动条,但我不知道当用户滚动那个滚动条时如何编写代码。
Please give me some sample codes or links
请给我一些示例代码或链接
采纳答案by bluecoder
For what you are describing, you just need to set the form's Autoscroll property to true. (It is under the "Layout" section). Right-click on the form and select "Properties"
对于您所描述的内容,您只需要将表单的 Autoscroll 属性设置为 true。(它位于“布局”部分下)。右键单击表单并选择“属性”
This will add scroll bars if the form doesn't fit into the current window size. No code is required. The scroll bars will only appear when there is a control outside the current view.
如果表单不适合当前窗口大小,这将添加滚动条。不需要代码。只有在当前视图之外有控件时才会出现滚动条。
Reading your description again, what you might be looking for is a large panel in your form. Add a Panel to your form and make set the location to 0,0 and the size to 992,1403. Then add your controls to the panel. Don't forget to set the form's Autoscroll as mentioned above.
再次阅读您的描述,您可能会在表单中寻找一个大面板。在表单中添加一个面板,并将位置设置为 0,0,将大小设置为 992,1403。然后将您的控件添加到面板。不要忘记如上所述设置表单的自动滚动。