Skip to main content

Example: TreeList.ColumnCount, TreeList.Columns

The following sample code populates a string list with column captions. The GetColumnsList method uses the Columns and ColumnCount properties to get access to the collection of columns within the control and to determine the number of columns within the collection.

Note that the AColumns parameter passed to the GetColumnsList method should be already initialized.

procedure GetColumnsList(AColumns: TStringList);
var
  I: Integer;
begin
  for I := 0 to cxTreeList.ColumnCount - 1 do
    AColumns.AddObject(cxTreeList.Columns[I].Caption.Text, cxTreeList.Columns[I]);
end;