垂直滚动条添加到面板.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);
详细的讨论在这里:http://social.msdn.microsoft.com/Forums/en-IE/winforms/thread/6b9c2c72-e91a-40f0-a835-c12328490c0c