I am using TListView in virtual mode (OwnerData set to true) and that is simple enough. TListView is in vsReport view style and uses main Caption and SubItems. The event code for OnData is simple (the code is C++ Builder but you'll figure it out if you use Delphi):
void __fastcall TForm1::ListView1Data(TObject *Sender, TListItem *Item)
{
Item->Caption = MyList[Item->Index].Name;
Item->SubItems->Add(MyList[Item->Index].Status);
}
All good so far, but I am puzzled by SubItems->Add - is that a memory leak to continuously add SubItems like that (also goes for Caption)?
Am I supposed to free the memory in an another event (which I haven't found yet)?
No it is not a memory leak. The framework allocated the
SubItemsobject, and it deallocates it when it has finished using it.