使用自动滚动进行平滑滚动 [英] smooth scroll with autoscroll

查看:157
本文介绍了使用自动滚动进行平滑滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows窗体上有一个面板。面板启用了自动滚动功能。滚动条的显示方式与滚动条一样,滚动条的操作方式与它们应该一样。

但面板的内容只有在释放鼠标按钮时才会更新。滚动条移动时如何使内容滚动。 (我想复制大多数现代程序的滚动行为,例如文字处理器和网页浏览器......立即移动滚动条和内容也滚动。)



我正在使用C#,Visual Studio 2008 pro和Windows XP-pro。

解决方案



挂钩面板的滚动事件,并在事件处理程序中放入如下代码:

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

其中e是传递给事件处理程序的ScrollEventArgs对象。



水平的类似代码。



我不知道为什么这不是自动的,或者为什么没有至少有一个财产要实现它。


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.

这篇关于使用自动滚动进行平滑滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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