简体   繁体   English

100万行ListView

[英]1-million-row ListView

I have a SysListView32 that should potentially host millions of rows, and three columns of text A, B, C each < 256 characters. 我有一个SysListView32应该可以托管数百万行,三列文本A,B,C每个<256个字符。

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). 假设列B有很多次重复(例如:列A是文件名,列B是路径,每行是文件系统的文件),并且只有100k不同的值(而不是几百万)。

Is it possible to avoid duplication in RAM of content of column B of the ListView GUI element? 是否可以避免ListView GUI元素的B列内容的RAM重复?

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? 我们可以只用指向数组元素的指针填充ListView (取自B列不同值的100k元素数组),而不是重复数据吗?

How to modify this to make it work? 如何修改它以使其工作?

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

What you need is also referred as "Virtual List". 您需要的还称为“虚拟列表”。 A virtual list control is a list view control that has the LVS_OWNERDATA style. 虚拟列表控件是具有LVS_OWNERDATA样式的列表视图控件。 This style enables the control to support an item count up to a DWORD (the default item count only extends to an int). 此样式使控件能够支持最多DWORD项目(默认项目计数仅扩展为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. Add LVS_OWNERDATA style to your ListView 将LVS_OWNERDATA样式添加到ListView
  2. Make a call to CListCtrl::SetItemCount passing the data source size, like std::vector::size(). 调用CListCtrl :: SetItemCount传递数据源大小,如std :: vector :: size()。
  3. Catch the LVN_GETDISPINFO notification. 捕获LVN_GETDISPINFO通知。 This is where the data is rendered into the ListCtrl. 这是将数据呈现到ListCtrl的位置。

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 . 如果您使用CListView,您可以使用GetListCtrl访问CListCtrl。

Links: 链接:

Virtual List Controls 虚拟列表控件

Using virtual lists 使用虚拟列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM