tp.Collection

tp.Collection extends tp.List, but it is meant for objects that belong to a parent collection. Its items are tp.CollectionItem objects, or objects with a compatible Collection property. When an item is inserted, the collection sets item.Collection to itself.

This makes tp.Collection useful for owned child objects: columns in a grid, menu items, named descriptors, and similar structures. It also supports copying source items through Clone() or Assign(), so assigning one collection to another does not reuse the same item instances.

Current collection

The collection below contains custom DemoColumn items.


                        

Owned items

Add() with no item creates a new item using the configured ItemClass. Inserted items get a back-reference to the collection.

Copying source items

AddRange() and Assign() copy collection items. The demo item implements Clone(), so copied items are new instances.

List behavior

Because tp.Collection extends tp.List, it still supports list events, FindBy(), ContainsBy(), and GetEnumerator().