垂直滚动条添加到面板.NET [英] Add vertical scroll bar to panel in .NET

查看:386
本文介绍了垂直滚动条添加到面板.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找了一段时间的教程获得只是一个单一的垂直滚动条在面板上(并得到它的工作权等)我试图做一个面板可滚动的,但只有垂直滚动的(所以自动滚屏将不能工作,因为子控件晃过左边缘必须)。所以,这是怎么做的?这可能已经问过,但我不能在任何地方找到它。

I've been searching for a while for a tutorial on getting just a single vertical scrollbar on a panel (and getting it to work right, etc.) I am trying to make a panel scrollable, but vertically scrollable only (so AutoScroll won't work because the child controls go past the left edge and must). So how is this done? This has probably been asked before but I can't find it anywhere.

推荐答案

假设你正在使用的WinForms,默认的面板组件不能为您提供一种方法来禁用水平滚动元件。这方面的一个解决方法是禁用自动滚动,并添加滚动条自己:

Assuming you're using winforms, default panel components does not offer you a way to disable the horizontal scrolling components. A workaround of this is to disable the auto scrolling and add a scrollbar yourself:

ScrollBar vScrollBar1 = new VScrollBar();
vScrollBar1.Dock = DockStyle.Right;
vScrollBar1.Scroll += (sender, e) => { panel1.VerticalScroll.Value = vScrollBar1.Value; };
panel1.Controls.Add(vScrollBar1);

详细的讨论在这里:<一href=\"http://social.msdn.microsoft.com/Forums/en-IE/winforms/thread/6b9c2c72-e91a-40f0-a835-c12328490c0c\">http://social.msdn.microsoft.com/Forums/en-IE/winforms/thread/6b9c2c72-e91a-40f0-a835-c12328490c0c

这篇关于垂直滚动条添加到面板.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆