smooth scroll with autoscroll

泄露秘密 提交于 2019-12-23 19:08:41

问题


I have a Panel on a Windows Form. The Panel has autoscroll enabled. The scroll bars appear as they should and the scroll bars generally operate as they should.

But the content of the panel is only updated when the mouse button is released. How can I make the content scroll AS the scroll bar is moved. (I want to duplicate the scroll behavior of most modern programs such as word processors and web browsers... move the scroll bar and the content immediately scrolls as well.)

I am using C#, Visual Studio 2008 pro, and Windows XP-pro.


回答1:


I finally found a hint on the web, and it works.

Hook the panel's scroll event, and in the event handler, put code like this:

if (e.ScrollOrientation == ScrollOrientation.VerticalScroll) {
  panel1.VerticalScroll.Value = e.NewValue;
}

where e is the ScrollEventArgs object passed to the event handler.

Similar code for horizontal, of course.

I don't know why this isn't automatic, or why there isn't at least a property to make it happen.



来源:https://stackoverflow.com/questions/2714585/smooth-scroll-with-autoscroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!