Recent

Author Topic: ListView and ownerdata question  (Read 5483 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
ListView and ownerdata question
« on: July 12, 2010, 09:01:47 pm »
Hi,

When I'm using ownerdata it uses more RAM?
Code: [Select]
procedure TForm1.ListView1Data(Sender: TObject; Item: TListItem);
begin
  Item.Caption := MyCollection.Item[Item.Index].Name;
  Item.Subitems.Add(MyCollection.Item[Item.Index].Surname);
end; 

In the above code to each item is assigned contents of my own structure, so it is duplicated. Maybe it should be an event that gets the data only for the current drawing item?

P.S. I did experience. I Compared speed of "ownerdata" between TListView and TVirtualTreeView. I'm surprised because the load 10 000 000 items in TVirtualTreeView lasts 14 seconds and in TListView just 3.5 seconds. This is a very good result.

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: ListView and ownerdata question
« Reply #1 on: July 12, 2010, 11:48:38 pm »
In the above code to each item is assigned contents of my own structure, so it is duplicated.
Which is a bad thing. Do not make changes to the listview structure in the OnData event.

Quote
Maybe it should be an event that gets the data only for the current drawing item?
This is the VirtualTree design paradigm...

Quote
P.S. I did experience. I Compared speed of "ownerdata" between TListView and TVirtualTreeView. I'm surprised because the load 10 000 000 items in TVirtualTreeView lasts 14 seconds and in TListView just 3.5 seconds. This is a very good result.
Hm, I doubt that. VirtualTree is pretty fast with the insertion of new records because of the way it's designed. If you compare it with TListView and it's 4x slower, then you're most likely not comparing the same basic operations,
« Last Edit: July 12, 2010, 11:51:11 pm by eny »
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Chronos

  • Full Member
  • ***
  • Posts: 241
    • PascalClassLibrary
Re: ListView and ownerdata question
« Reply #2 on: July 14, 2010, 08:40:26 am »
OnData event is executed only for visible items so it has same behavior as concept of "virtual" list. So items data are loaded on demand direct from your list structure as TList, TObjectList, ...

VirtualTreeView should be slower because it can handle work with three whereas TListView is just list of item. To display virtual tree, component have to know about levels and count of items in expanded nodes so handling item list with treeview component should be slower when with list view component.

 

TinyPortal © 2005-2018