[Overview][Constants][Types][Classes][Procedures and functions][Variables] | Reference for unit 'Classes' (#fcl)

# TCollection

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Base class to manage collections of named objects.

## Declaration

`type TCollection = class(TPersistent)`
`protected`
`function GetAttrCount; dynamic;` |  | Returns the count of attributes associated with each item.
`function GetAttr(); dynamic;` |  | Returns an attribute of the collection.
`function GetItemAttr(); dynamic;` |  | Returns the attributes of an item.
`function GetNamePath; override;` |  | Overrides TPersistent.GetNamePath to return a proper pathname.
`procedure Changed;` |  | Procedure called if an item is added to or removed from the collection.
`function GetItem();` |  | Read handler for the TCollection.Items property.
`procedure SetItem();` |  | Write handler for the TCollection.Items property.
`procedure SetItemName(); virtual;` |  | Virtual method to set the name of the specified item
`procedure SetPropName; virtual;` |  | Write handler for the TCollection.PropName property
`procedure Update(); virtual;` |  | Hander called when an item in the collection has changed.
`property PropName: String; [rw]` |  | Name of the property that this collection represents.
`public`
`constructor Create();` |  | Creates a new collection.
`destructor Destroy; override;` |  | Destroys the collection and frees all the objects it manages.
`function Add;` |  | Creates and adds a new item to the collection.
`procedure Assign(); override;` |  | Assigns one collection to another.
`procedure BeginUpdate;` |  | Start an update batch.
`procedure Clear;` |  | Removes all items from the collection.
`procedure EndUpdate;` |  | Ends an update batch.
`function FindItemID();` |  | Searches for an Item in the collection, based on its TCollectionItem.ID property.
`property Count: Integer; [r]` |  | Number of items in the collection.
`property ItemClass: TCollectionItemClass; [r]` |  | Class pointer for each item in the collection.
`property Items: TCollectionItem; [rw]` |  | Indexed array of items in the collection.
`end;`

## Inheritance

`TCollection` |  | Base class to manage collections of named objects.
`TPersistent` |  | Base class for streaming system and persistent properties.
`TObject`

## Description

TCollection implements functionality to manage a collection of named objects. Each of these objects needs to be a descendent of the TCollectionItem class. Exactly which type of object is managed can be seen from the TCollection.ItemClass property.

Normally, no TCollection is created directly. Instead, a descendents of TCollection and TCollectionItem are created as a pair.

## See also

TCollectionItem |  | Basic object that is managed by a TCollection class.