List of data, ListView updates faster

xiaoxiao2021-03-06  100

Handling ListView with conventional methods, no matter whether it is a large amount of data, whether it is still use of beginupdata and endupdata () or the handle of WM_ERASEBKGND data will not be ideal, what is the answer? Well, use the so-called Virtual ListView. It is very simple to say that it is very simple.

The ListView-> OwnerData is set to True, then set directly to the total number of data. The actual data can keep any other vessels that are faster and can index (such as the Vector in STL). Then the key is to write code in the onData event to remove the data from the container (such as vector), then use item-> caption = ???; item-> subs-> add (???); item -> SUBITEMS-> add (???); to dynamically write data to ListView for UI display, so Virtual ListView is complete. A complete simple example is as follows: /*Unit1.h*// --- -------------------------------------------------- ---------------------- # $ifndef unit1h #define unit1H // -------------------- -------------------------------------------------- ----- #include #include #include #include #include #include Using Namespace Std; / / --------------------------------------------------- -------------------------- Struct ListViewData {Ansistring Caption; Ansistring Subitems1; Ansistring Subitems2; Ansistring Subitems3;}; Class TFORM1: Public TFORM {__published : // IDE-management Components TlistView * listview1; void __fastcall listview1data (TOBJECT * SENDER, TLISTITEM * ITEM); private: / / User declarations vector m_lvdatavector; public: // user declarations __fastcall tform1 (tComponent * Owner); __fastcall ~ tform1 ();}; // ---------------- -------------------------------------------------- --------- EXTERN PACKAGE TFORM1 * FORM1; / / --------------------------------- ------------------------------------------ #ndif /*Unit1.cpp* / / / -------------------------------------------------------------------------------------------- ---------------------------- #include #pragma hdrstop #include "unit1.h" // --- -------------------------------------------------- ---------------------- #pragma package (smart_init) #pragma resource "* .dfm"

转载请注明原文地址:https://www.9cbs.com/read-96898.html

New Post(0)