Programming Delphi TCollection, TStringList and THashedStringList Descriptions in Delphi or C++Builder

This article give you descriptions to the TCollection, TStringList and THashedStringList in Delphi / C++Builder. These base vcl/clx component are very useful in programming.


TCollection is a container for TCollectionItem objects.

TCollection is in Unit Classes.


Each TCollection holds a group of TCollectionItem descendants. TCollection maintains an index of the collection items in its Items array. The Count property contains the number of items in the collection. Use the Add and Delete methods to add items to the collection and delete items from the collection.

Objects descended from TCollection can contain objects descended from TCollectionItem. Thus, for each TCollection descendant, there is a corresponding TCollectionItem descendant. The following table lists some typical descendants of TCollection with the corresponding TCollectionItem descendant and the component that uses each pair.

TCollection descendant
TCollectionItem descendant
TAggregates TAggregate TClientDataSet
TCookieCollection TCookie TWebResponse
TDBGridColumns TColumn TDBGrid
TFieldDefs TFieldDef TDataSet
THeaderSections THeaderSection THeaderControl
TListColumns TListColumn TListView
TParams TParam many datasets
TStatusPanels TStatusPanel TStatusBar

The controls that use TCollection and TCollectionItem descendants have a published property that holds a collection. (For example, the Panels property of TStatusBar holds a TStatusPanels.) A standard property editor, referred to generically as the Collection editor, can be invoked from the Object Inspector to edit the items in the collection.

Note: When writing a TCollection descendant that is used by another control, be sure to override the protected GetOwner method of the collection so that it can appear in the Object Inspector.


TStringList maintains a list of strings.

TStringList is in Unit Classes.


Use a string list object to store and manipulate a list of strings. TStringList implements the abstract properties and methods introduced by TStrings, and introduces new properties, events, and methods to

Sort the strings in the list.
Prohibit duplicate strings in sorted lists.
Respond to changes in the contents of the list.
Control whether strings are located, sorted, and identified as duplicates in a case-sensitive or case-insensitive manner.


THashedStringList maintains a list of strings using an internal hash table.

THashedStringList is in Unit IniFiles.


THashedStringList is a string list that uses a hash table internally to speed the process of locating strings. It is used internally by TMemIniFile to manage the strings from an INI file, but can be used in the same way as any other string list. By using THashedStringList instead of TStringList, you can improve performance when the list contains a large number of strings.

Add comment

Security code

Programming - Delphi