Collection¶
Qualified name: delphifmx.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
Adds a collection item to the collection
Copies the contents of the Source collection to the current object.
Suspends screen repainting.
Clears all collection items
Embarcadero Technologies does not currently have any additional information.
Deletes a single item from the collection.
Re-enables screen repainting.
Returns the item with the specified ID.
Returns a TCollection enumerator.
Returns a string used by the Object Inspector.
Inserts a new collection item to the collection at the Index position
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 count of collection items
bool:
Indicates the class to which the collection's items belong.
Returns an iterator over the collection items
Returns the Owner of the collection
- Add()¶
Adds a collection item to the collection
- Assign(Source: Persistent) None ¶
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()¶
Suspends screen repainting.
- 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.
- Type:
int
- Clear()¶
Clears all collection items
- ClearAndResetID()¶
Embarcadero Technologies does not currently have any additional information.
- Count¶
Returns the count of collection items
- Delete(Index)¶
Deletes a single item from the collection.
- EndUpdate()¶
Re-enables screen repainting.
- FindItemID(ID: int) 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.
- 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)¶
Inserts a new collection item to the collection at the Index position
- IsEmpty¶
bool:
- 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.
- Type:
CollectionItemClass
- Items¶
Returns an iterator over the collection items
- Owner¶
Returns the Owner of the collection
- Sort(AComparer: IComparer<System.Classes.CollectionItem>) None ¶
Embarcadero Technologies does not currently have any additional information.