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

# TCollection

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

Base class to manage collections of named objects.

## Declaration

Source position: classesh.inc line 522

`type TCollection = class(TPersistent)`
`public`
`constructor Create();` |  | Creates a new collection.
`destructor Destroy; override;` |  | Destroys the collection and frees all the objects it manages.
`function Owner;` |  | Owner of the collection.
`function Add;` |  | Creates and adds a new item to the collection.
`procedure Assign(); override;` |  | Assigns one collection to another.
`procedure BeginUpdate; virtual;` |  | Start an update batch.
`procedure Clear;` |  | Removes all items from the collection.
`procedure EndUpdate; virtual;` |  | Ends an update batch.
`procedure Delete();` |  | Delete an item from the collection.
`function GetEnumerator;` |  | Create an IEnumerator instance
`function GetNamePath; override;` |  | Overrides TPersistent.GetNamePath to return a proper pathname.
`function Insert();` |  | Insert an item in the collection.
`function FindItemID();` |  | Searches for an Item in the collection, based on its TCollectionItem.ID property.
`procedure Exchange();` |  | Exchange 2 items in the collection
`procedure Move();`
`procedure Sort();` |  | Sort the items in the collection
`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,IFPObserved` |  | Base class for streaming system and persistent properties.
`TObject` |  | Base class of all classes.

## Description

TCollection implements functionality to manage a collection of named objects. Each of these objects needs to be a descendant 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 descendants of TCollection and TCollectionItem are created as a pair.

## See also

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

Documentation generated on: May 14 2021