Author: Jonas Bilinkevicius
The TListView control is very slow if it contains a large amount of items. How do
you accelerate it?
One possibility is to use the functions
This is still not enough for very large ListViews with more than 20.000 Items. Here
it is better to use virtual ListViews :
1. Set Listview.OwnerData to "true"
2. Use the OnData-Event of the Listview-Component, e.g. :
1 2 procedure TForm.ListViewData(Sender: TObject; Item: TListItem);
3 var4 n: integer;
5 s: string;
6 begin7 Item.SubItems.Clear;
8 for n := 1 to FList.Count - 1 do9 begin10 s := tStrings(FList[n])[Item.Index];
Of course you can not use TListView.AlphaSort to sort this kind of ListView. If you
want to sort it, you have to write your own sort procedure.
The same method can be applied to accelerate TListBox Components with a large
number of items:
set TListBox.Style to lbVirtual and use the OnData Event.