ListView and ownerdata question lazarus / 31-LCL ---------------------------------------------------------------------- Dibo · 2010-07-12 19:01 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 · 2010-07-12 21:48 Quote from: Dibo on July 12, 2010, 09:01:47 pmIn 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. QuoteMaybe it should be an event that gets the data only for the current drawing item?This is the VirtualTree design paradigm... QuoteP.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, ---------------------------------------------------------------------- Chronos · 2010-07-14 06:40 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.