I am testing the virtual listview in Delphi, with the following codes:
procedure TForm1.Button1Click(Sender: TObject);
var
Index: Integer;
begin
for Index := 0 to 4000 do
ListView1.Items.Count := Index;
end;
procedure TForm1.ListView1Data(Sender: TObject; Item: TListItem);
var
DebugStr: string;
begin
DebugStr := Format('Item.Index = %u' + #10#13, [Item.Index]);
OutputDebugString(PChar(DebugStr));
end;
Based on my test, even if the list only shows the first several items, and do not need the data of the remaining. It will still call OnData to obtain all the data for the remaining items. Why?
Originally I think it is implemented as a lazy-load method so only when the data are required, they will be requested via OnData event.