一百万行ListView [英] 1-million-row ListView

查看:127
本文介绍了一百万行ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SysListView32,可能应容纳数百万行,并且三列文本A,B,C分别< 256个字符.

I have a SysListView32 that should potentially host millions of rows, and three columns of text A, B, C each < 256 characters.

让我们说B列有很多重复(例如:A列是文件名,B列是路径,每一行是文件系统的文件),并且只有10万个不同的值(而不是几百万个).

Let's say column B has many many repetitions (example: column A is filename, column B is path, and each row is a file of the filesystem), and has only 100k different values (instead of several millions).

是否可以避免ListView GUI元素B列的内容在RAM中重复?

Is it possible to avoid duplication in RAM of content of column B of the ListView GUI element?

我们可以只用指针填充ListView来数组元素(取自B列不同值的100k元素数组),而不是重复的数据吗?

Can we fill a ListView with only pointers to arrays elements (taken from the 100k-element-array of different values of column B), instead of duplicated data?

如何对其进行修改以使其起作用?

How to modify this to make it work?

LV_ITEM item;
item.mask = LVIF_TEXT;
item.pszText = "Hello";
...
ListView_SetItem(hList, &item);

推荐答案

您所需的内容也称为虚拟列表".虚拟列表控件是具有LVS_OWNERDATA样式的列表视图控件.这种样式使控件能够支持最多DWORD的项目计数(默认项目计数仅扩展到int).但是,此样式提供的最大优点是可以在任何时候仅在内存中保留数据项的子集.这允许虚拟列表视图控件适合用于大型信息数据库,在该数据库中已经存在访问数据的特定方法.对于给定的一组数据(列表或动态数组),您需要执行以下步骤:

What you need is also referred as "Virtual List". A virtual list control is a list view control that has the LVS_OWNERDATA style. This style enables the control to support an item count up to a DWORD (the default item count only extends to an int). However, the biggest advantage provided by this style is the ability to only have a subset of data items in memory at any one time. This allows the virtual list view control to lend itself for use with large databases of information, where specific methods of accessing data are already in place. For a given set of data (list or dynamic array), you need to follow these steps:

  1. 将LVS_OWNERDATA样式添加到您的ListView
  2. 调用CListCtrl :: SetItemCount传递数据源大小,例如std :: vector :: size().
  3. 捕获LVN_GETDISPINFO通知.这是将数据呈现到ListCtrl中的位置.

请查看我添加的附件链接,以获取更多信息和示例代码.如果您使用CListView,则可以使用 GetListCtrl .

Please have a look at the attached links I added, for more information and sample code. If you use CListView you can have access to the CListCtrl with GetListCtrl.

链接:

虚拟列表控件

使用虚拟列表

这篇关于一百万行ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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