开发者

smooth scroll with autoscroll

开发者 https://www.devze.com 2022-12-28 00:27 出处:网络
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.

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号