Hi Folks, I am having a very silly problem and hope someone can suggest a reason.
I find that, in my app, the method that the ListView in OwnerData mode uses to get the necessary data (ie the OnData event, eg ListView1Data() ) is being called for the full dataset, not just the visible data. So I made a small demo but it works as expected, that is, the OnData event is only called for the data that is visible.
Trying to work out what was different, I ended up adding a new ListView to may app, changing only the ViewStyle to vsReport, OwnerData to True and setting ListView1.Items.Count := 5000. In my app, this calls ListView1Data() 5000 times, in my demo, exactly the same code, its called 10 or so times.
This is all I have changed in both my demo and my app -
procedure TMainForm.FormCreate(Sender: TObject);
begin
....
ListView1.ViewStyle:= vsReport;
ListView1.OwnerData := True;
ListView1.Items.Count := 5000;
end;
procedure TMainForm.ListView1Data(Sender: TObject; Item: TListItem);
begin
Item.Caption := inttostr(Item.Index);
debugln('TMainForm.ListView1Data - ' + inttostr(Item.Index));
end;
But in the small demo, I see 10 or so calls, in the App, I see 5000. It has to be something to do with the project but the above code is the ONLY explicit interaction with the app. I have tried changing the memory manager and enabling threading in the demo ('cos thats how my app is). "Clean up and Build", debugging on and off, different optimization. I work with Lazarus 2.2rc2 but its exactly the same with Main.
Can anyone suggest a reason ? I assume it has to do with my project, its a reasonably big build ....
Davo