如何添加/删除项目在虚拟模式下一个ListView? [英] How do I add/remove items to a ListView in virtual mode?

查看:160
本文介绍了如何添加/删除项目在虚拟模式下一个ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用虚拟模式一个ListView话,我的理解是,列表视图只跟踪少数在列表中的项目。当用户滚动它动态地获取它需要从虚拟列表中显示的项目。

If I'm using a ListView in virtual mode then, as I understand it, the list view only keeps track of a small number of items in the list. As the user scrolls it dynamically retrieves items it needs to show from the virtual list.

但是,如果项目被添加或从主列表中删除?如果一个项目被添加/索引的范围之外,卸下被显示在列表视图,然后我会假设列表视图中会显示添加/遗失物品的用户滚动到该索引时。它是否正确?但是,如果一个项目添加/索引的用户正在观看的范围中删除?我如何触发列表视图刷新当前正在查看以显示新的/丢失物品的项目?

But what if an item is added or removed from the master list? If an item is added/removed outside of the range of indexes being shown by the list view then I would assume the list view would show the added/missing items when the user scrolls to that index. Is this correct? But what if an item is added/removed from the range of indexes the user is currently viewing? How do I trigger the list view to refresh the items it is currently viewing to show the new/missing items?

供参考:我使用的是 ObjectListView 如果让任何区别

FYI: I'm using an ObjectListView if that makes any difference.

推荐答案

一个虚拟列表什么都不知道关于你的产品清单。它不跟踪它们,甚至不是一个小套。它永远只能问:你有什么想显示在第n行?

A virtual list knows nothing about your list of items. It doesn't keep track of them, not even a small set. It only ever asks "what do you want to show at the n'th row?"

如果您的主列表发生变化,所有你需要做的是重绘列表。 的Invalidate()会为你做的。然后,列表视图会问你再次它应该显示在每行的控制可见。

If your master list changes, all you need to do is redraw the list. Invalidate() will do that for you. The listview will then ask you again what it should show at every row visible in the control.

如果您使用的是ObjectListView,你有没有考虑使用FastObjectListView,让你的虚拟列表的速度好处和易用性正常ObjectListView的?

If you are using ObjectListView, have you considered using the FastObjectListView which gives you the speed benefits of a virtual list and the ease of use of a normal ObjectListView?

这篇关于如何添加/删除项目在虚拟模式下一个ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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