使用 VirtualMode=True 时如何更新 WinForms ListView?

发布于 2024-07-07 20:44:47 字数 462 浏览 8 评论 0原文

我有一个带有大 ListView 的应用程序,它非常慢,所以我正在实现 VirtualMode。 MSDN 似乎没有介绍如何在列表视图中间添加和删除新项目。

例如,ListView 有 1000 个项目(表示磁盘上的文件),在 ListView 初始填充后(通过 RetrieveVirtualItem 事件),一些文件将被删除,一些文件将被添加,以便 VirtualListSize 在更新后甚至可能相同。

问题 1) 我如何对 ListView 说“这些项目已被更改/删除”以便它重新查询?

此外,某些文件只是发生了变化,我想在列表视图中反映它们更改后的状态。

问题 2) 鉴于 VirtualMode 不允许我访问之前使用的 Items 集合(我在该集合上使用了 ContainsKey 方法),如何在列表视图中查找项目。

听起来很容易,但我自己看不到。 非常感谢帮助。

瑞安

I have an app with a large ListView which is terribly slow so I'm implementing VirtualMode. MSDN does not seem to cover how I would add and delete new items in the middle of the listview.

For example, the ListView has 1000 items (representing files on disk) and after the initial population of the ListView (by the RetrieveVirtualItem event) some files will be deleted and some added so that VirtualListSize might even be the same after the update.

Question 1) How do I say to the ListView 'these items have been changed/deleted' so that it requeries?

Additionally, some of files just change and I'd like to reflect their changed status in the listview.

Question 2) How do I find an item in the listview given that VirtualMode does not let me access the Items collection that I was using before (I used the ContainsKey method on that collection).

Sounds easy, but I can't see it myself. Help greatly appreciated.

Ryan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永言不败 2024-07-14 20:44:47

要添加或删除项目,只需将 VirtualListSize 设置为项目总数。 要刷新单个项目,请使用 RedrawItems。

要定位特定项目,您可以使用已有的容器,而不是返回到 ListView。 列表中的索引应与 ListView 中的项目匹配。

To add or delete items, simplay set VirtualListSize to the total count of items. To refresh individual items use RedrawItems.

To locate a particular item, you use the container you already have, don't go back to the ListView. The indicies within your list should match up with the items from the ListView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文