Re:Items count
"Andrew Fedoseev" <
XXXX@XXXXX.COM >wrote in message
Quote
i have a ListView component on the main form which is designated
to show something around 1500 records (items). These records i
read from file using TFileStream class and save them to TList.( Each
TList item is a pointer to a struct.) After this i add items to ListView
and put the captions accordingly to a TList structures.
For that many items, and especially since you already have the struct data
stored in memory, you should be using the ListView in virtual mode
(OwnerData property is set to true and you have an OnData event handler), if
you are not already. There is no need to duplicate the data in the
ListView, and thus use twice as much memory, when it can use your existing
TList data memory directly. For example:
TList *MyList;
void __fastcall TForm1::LoadFile()
{
// make sure OwnerData=true beforehand ...
// open file, fill in TList as needed, then...
ListView1->Items->Count = MyList->Count;
}
void __fastcall TForm1::ListView1Data(TObject *Sender, TListItem *Item)
{
MyStruct *S = (MyStruct*) MyList->Items[Item->Index];
Item->Caption = S->Whatever;
// fill in other TListItem properties as needed...
}
Quote
But when i Close the form - after all the memory i use have released -
i get acces violation within inline __fastcall virtual ~TForm(void) { }.
Something is probably trying to access your memory after you have freed it.
Quote
Just curious - are there any limitations for the Tlist'Count property
TList is limited only by available memory.
Quote
and ListView'->Items->Count property?
If you are not using the ListView in virtual mode, then the ListView has
limited memory available for its items. 1500 is a lot of items for a
ListView to manage.
Gambit