Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS Advanced Poly List
Adding / removing items

The poly list has a polymorph collection of TCustomItem classes. Each descending class inherits all properties and can also be added to the collection. To access the properties specifically for a descending item, the item must be added to the list and typecasted to the correct class to gain access to the properties.

Adding an item:
with TTextItem(AdvPolyList1.AddItem(TTextItem)) do
begin
  Caption := 'This is a sample';
end;

Inserting an item at a specific position in the collection:
with TTextItem(AdvPolyList1.InsertItem(0, TTextItem)) do
begin
  Caption := 'This is a sample';
end;

Removing an item at a specific position:
AdvPolyList1.RemoveItem(0);

To compile the project, the unit must manually be added to the uses list. In this case the unit is GDIPTextItem which contains the TTextItem class.

The rule for adding the correct unit is:
(T)CustomItem -> (GDIP)CustomItem
Class -> Unit

When you are not sure what unit you must add to compile the project, you can always add the item of choice at designtime, so the unit is automatically added to the uses list.

This is also explained at page 12 of the PDF Developers Guide