System.Contnrs.TComponentList.Items

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property Items[Index: Integer]: TComponent read GetItems write SetItems; default;

C++

__property System::Classes::TComponent* Items[int Index] = {read=GetItems, write=SetItems/*, default*/};

Properties

Type Visibility Source Unit Parent
property public
System.Contnrs.pas
System.Contnrs.hpp
System.Contnrs TComponentList

Description

Lists the component references.

Use Items to access components in the list. Items is a zero-based array: The first component is indexed as 0, the second component is indexed as 1, and so forth. You can read or change the value at a specific index, or use Items with the Count property to iterate through the list.

If OwnsObjects is true, reassigning an Items value frees the component that previously occupied that position in the list.

Items can contain nil (Delphi) or NULL (C++) references. To remove nil (Delphi) or NULL (C++) references and reduce the size of the array, call the Pack method.

Note: In Delphi, Items is the default property of TComponentList. This means that the property name can be eliminated in code that uses this property. Thus, the following two lines are both acceptable and do the same thing:

ComponentList1->Items[i] := Screen.CustomForms[i]; ComponentList1[i] := Screen.CustomForms[i];

Note: In C++, Items can be accessed using the [] operator, to achieve an effect similar to the default property in Delphi.

See Also