TcxCustomTreeList.Bands Property
Provides access to all bands in the Tree List control.
Declaration
property Bands: TcxTreeListBands read; write;
Property Value
| Type | Description |
|---|---|
| TcxTreeListBands | A collection of tree list bands. |
Remarks
Bands are headers designed to group related columns in Tree List controls. Use the Bands property to manage bands in the Tree List control.
Available Options
Call the Bands.Add function to create a new band as demonstrated in the following code example: Create and Populate Unbound Tree List Controls. To access individual bands, you can use Bands.BottomItems, Bands.Items, Bands.RootItems, Bands.VisibleItems, and other related properties.
Refer to the TcxTreeListBands class description for detailed information on all available options.
Code Example: Create and Populate Unbound Tree List Controls
The following code example creates a TcxTreeList control with three columns and populates it with nodes arranged into a tree-like hierarchy (in unbound mode):
uses
cxTL; // Declares the TcxTreeList control and related types
// ...
var
ATreeList: TcxTreeList;
ABand: TcxTreeListBand;
AColumn: TcxTreeListColumn;
ARootNode, ANode, AChildNode: TcxTreeListNode;
begin
ATreeList := TcxTreeList.Create(Self); // Creates a TcxTreeList control
ATreeList.Parent := Self; // Associates the created control with the parent form
ATreeList.BeginUpdate; // Initiates the following batch operation
try
ATreeList.Align := alClient;
// Create a band and three columns
ABand := ATreeList.Bands.Add;
ABand.Caption.Text := 'General Information';
AColumn := ATreeList.CreateColumn(ABand);
AColumn.Caption.Text := 'Name';
AColumn := ATreeList.CreateColumn(ABand);
AColumn.Caption.Text := 'Distance (000km)';
AColumn := ATreeList.CreateColumn(ABand);
AColumn.Caption.Text := 'Period (days)';
// Create all nodes and assign values
ARootNode := ATreeList.Add;
ARootNode.Values[0] := 'Sun';
ANode := ATreeList.AddNode(nil, ARootNode, nil, tlamAddChild);
ANode.Values[0] := 'Mercury';
ANode.Values[1] := 57910;
ANode.Values[2] := 87.97;
ANode := ATreeList.AddNode(nil, ARootNode, nil, tlamAddChild);
ANode.Values[0] := 'Venus';
ANode.Values[1] := 108200;
ANode.Values[2] := 224.7;
ANode := ATreeList.AddNode(nil, ARootNode, nil, tlamAddChild);
ANode.Values[0] := 'Earth';
ANode.Values[1] := 149600;
ANode.Values[2] := 365.26;
AChildNode := ANode.AddChild;
AChildNode.Values[0] := 'Moon';
AChildNode.Values[1] := 384;
AChildNode.Values[2] := 27.32;
ARootNode.Expand(True); // Expands all nodes starting from the root level
finally
ATreeList.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
ATreeList.ApplyBestFit; // Adjusts column width to fit all captions and content in full
end;
