的WinForms ListView的,在刷新记住滚动位置 [英] WinForms ListView, Remembering Scrolled Location on Reload

查看:134
本文介绍了的WinForms ListView的,在刷新记住滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了我要和用户数据的8列填充列表视图。用户必须启用自动刷新,这将导致ListView控件被清除,并与数据库中的最新数据重新填充的选项。

I've got a list view that I'm populating with 8 columns of user data. The user has the option to enable auto refreshing, which causes the ListView to be cleared and repopulated with the latest data from the database.

的问题是,当物品被清除并重新填充,可见区域跳回列表的顶部。所以,如果我期待在2000年项目1000年,这是非常不方便回到该项目。

The problem is that when the items are cleared and repopulated, the visible area jumps back to the top of the list. So if I'm looking at item 1000 of 2000, it's very inconvenient to get back to that item.

基本上,我问的是,如何获取当前的滚动距离(x和y),然后将其还原?

Basically, what I'm asking is, how do I get the current scroll distances (x and y) and then restore them?

推荐答案

我以前有一个,而同样的问题,我结束了实现算法与列表中的模型进行比较,所以我只补充说,有/删除元素改变。如果这样,没有巨大变化列表不跳开头。而我想实现的主要事情是效率(这样名单不闪烁)。

I had the same problem with a while ago and I ended up implementing an algorithm to compare the model with the list, so I only added/removed elements that had changed. This way if there were no massive changes the list didn't jump to the beginning. And the main thing I wanted to achieve was the efficiency (so that the list doesn't blink).

这篇关于的WinForms ListView的,在刷新记住滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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