Listview自动滚动到顶部 [英] Listview auto-scrolls to the top

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

问题描述

您好,我的表单中有一个listview(带有 Scrollable = true ),我正在使用循环填充它。在循环中,我调用 Application.DoEvents(),然后添加当前项( listview.add(...)),到目前为止一直很好。



如果以后我尝试添加更多项目而不点击/按任何列表视图正常行为,但如果我滚动使用鼠标滚轮,当它仍然添加项目时,listview会在每次添加项目时自动滚动到顶部。



长话短说:如何我可以在添加项目时将其停止自动滚动到顶部吗?



注意:如果我使用滚动条,这不会发生,箭头键或向上/向下翻页,同时它仍然只用鼠标滚轮添加项目。

Hello, I have a listview(with Scrollable = true) in my form and I''m populating it using a loop. In the loop I call Application.DoEvents() and then I add the current item( listview.add(...) ), so far so good.

If later I try to add some more items without clicking/pressing anything the listview behaves normally, but if I scroll using the mouse wheel while it''s still adding the items the listview auto-scrolls to the top each time an item is added.

Long story short: How can I stop it from auto-scrolling to the top when an item is added?

Note: this doesn''t happen if I use the scrollbar, the arrow keys or page up/down while it''s still adding items only with the mouse wheel.

推荐答案

添加项目后,调用item.EnsureVisible ()例程,用项目名称替换项目。这将总是滚动到最新的项目,如果你不想让它滚动,那么它是一个不同的问题。
After adding the item, call the item.EnsureVisible() routine, replacing item with your item name. This will always scroll to the newest item, if you don''t want it to scroll at all then its a different problem.


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

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