Collection#
Qualified name: delphivcl.Collection
- class Collection#
Bases:
Persistent
TCollection is a container for TCollectionItem objects. 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
Component
TBitmapLinks
TBitmapLink
TCustomStyleObject
TAggregates
TAggregate
TClientDataSet
TCookieCollection
TCookie
TWebResponse
TCoolBands
TCoolBand
TCoolBar
TDBGridColumns
TColumn
TDBGrid
TDependencies
TDependency
TService
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 the descendant class instances can appear in the Object Inspector. Note: TCollection has the TOwnedCollection descendant that maintains information about its owner. TOwnedCollection implements the GetOwner method. Therefore, classes derived from TOwnedCollection do not need to add anything in order to appear in the Object Inspector.
Methods
Creates a new TCollectionItem instance and adds it to the Items array.
Copies the contents of the Source collection to the current object.
Signals the start of an update operation.
Deletes all items from the collection.
Embarcadero Technologies does not currently have any additional information.
Creates and initializes a collection.
Deletes a single item from the collection.
Destroys the collection and each item in it.
Signals the end of an update operation.
Returns the item with the specified ID.
Returns a TCollection enumerator.
Returns a specified item in the collection.
Returns a string used by the Object Inspector.
Creates a new TCollectionItem instance and adds it to the Items array.
Returns the Owner of the collection.
Copies the properties of another item to a specified item in the collection.
Embarcadero Technologies does not currently have any additional information.
Attributes
Provides access to the internal TList.Capacity property.
ClassName
Returns the TObject.ClassName
Returns the number of items in the collection.
Indicates the class to which the collection's items belong.
<Delphi indexed property Items of type TCollection at 211416431C0>
- Add()#
Creates a new TCollectionItem instance and adds it to the Items array. Call Add to create an item in the collection. The new item is placed at the end of the Items array. Add returns the new collection item.
- Assign(Source: Persistent)#
Copies the contents of the Source collection to the current object. Use Assign to copy the contents of one TCollection instance to another. The Assign method deletes all items from the destination collection (the object where it is executed), then adds a copy of each item in the source collection’s Items array. Source is another object (typically another collection) that contains the items that replace this collection’s items.
- BeginUpdate()#
Signals the start of an update operation. Call BeginUpdate before starting an operation that performs changes to TCollection. After completing all the changes, call EndUpdate to signal the end of the operation. Every call to BeginUpdate must be matched by a corresponding call to the EndUpdate method. For example, the method is used to suspend screen repainting until changes to a component that involves TCollection are completed.
- Capacity#
Provides access to the internal TList.Capacity property. The Capacity property specifies the allocated size of the array of pointers maintained by the TList object. This value is set to the number of pointers the list will need to contain.
- Clear()#
Deletes all items from the collection. Clear empties the Items array and destroys each TCollectionItem.
- ClearAndResetID()#
Embarcadero Technologies does not currently have any additional information.
- Count#
Returns the number of items in the collection. Count contains the number of items in the Items array. Since Items is indexed starting with 0, the value of Count is always one greater than the index of the last member of Items.
- Create(ItemClass: CollectionItemClass)#
Creates and initializes a collection. Call Create to instantiate a TCollection object at run time. Typically, TCollection descendants are created by a component that uses the collection to implement a property. ItemClass identifies the TCollectionItem descendants that must be used to represent the items in the collection. The Add method uses this class to create items of the appropriate type.
- Delete(Index: Integer)#
Deletes a single item from the collection. Delete removes the specified collection item, moving up any items that come after that item in the Items property array. Index identifies the item to delete. This is the index of the item in the Items property array. 0 specifies the first item, 1 specifies the second item, and so on.
- Destroy()#
Destroys the collection and each item in it. Destroy uses the Clear method to free each item referenced in the Items array, then destroys the collection itself.
- EndUpdate()#
Signals the end of an update operation. Call EndUpdate after completing an operation that was preceded by a call to the BeginUpdate method. Every call to BeginUpdate must be matched by a corresponding call to the EndUpdate method. For example, use EndUpdate to re-enable screen repainting that was turned off with the BeginUpdate method for the components that involve TCollection.
- FindItemID(ID: Integer) CollectionItem #
Returns the item with the specified ID. The FindItemID method returns the item in the collection whose ID property is passed to it as a parameter. If no item has the specified ID, FindItemID returns nil (Delphi) or NULL (C++).
- GetEnumerator()#
Returns a TCollection enumerator. GetEnumerator returns a TCollectionEnumerator reference, which enumerates all items in the collection. To do so, call the TCollectionEnumerator GetCurrent method within a While MoveNext do loop.
- GetItem(Index: Integer) CollectionItem #
Returns a specified item in the collection. GetItem is the protected read implementation of the Items property.
- GetNamePath()#
Returns a string used by the Object Inspector. If the collection has no owner, GetNamePath returns the name of the collection’s actual (runtime) type. If the collection is owned, GetNamePath returns the owner’s name followed, if applicable, by a dot and the name of the owner’s property that holds the collection. For example, GetNamePath might return “TreeView1.Items”.
Note: For a collection to have an owner, it must override the GetOwner method.
- Insert(Index: Integer) CollectionItem #
Creates a new TCollectionItem instance and adds it to the Items array. Call Insert to add a new item at a specified position in the collection. Existing items (starting from the specified position) are moved up in the Items array. Insert returns the new collection item.
- ItemClass#
Indicates the class to which the collection’s items belong. ItemClass is the class (descended from TCollectionItem) to which the items in the collection belong. For example, in an instance of the TCollection descendant THeaderSections, the value of the ItemClass property is THeaderSection.
- Items#
<Delphi indexed property Items of type TCollection at 211416431C0>
- Owner()#
Returns the Owner of the collection. Call Owner to obtain a reference to the object that owns this collection. Typically, the owner uses the collection to implement one of its properties.
- SetItem(Index: Integer, Value: CollectionItem)#
Copies the properties of another item to a specified item in the collection. SetItem is the protected write implementation of the Items property. It calls the Assign method of the item specified by Index, so that the properties of the item specified by Value are copied to that item.
- Sort(AComparer: IComparer<System.Classes.CollectionItem>)#
Embarcadero Technologies does not currently have any additional information.