Skip to main content
A newer version of this page is available. .

TcxCustomTreeView.Items Property

Provides access to nodes of the tree view.

Declaration

property Items: TTreeNodes read; write;

Property Value

Type
TTreeNodes

Remarks

The Items property contains elements displayed within the tree view control. At design-time, this property can be used to create the hierarchical structure of nodes using the visual tree designer. This designer can be invoked by clicking the ellipsis button corresponding to the Items property.

The left pane of the dialog enables you to create a tree structure. The right pane is used to modify the properties of the currently selected node.

The Items property is represented by a TTreeNodes object. This object stores a collection of all nodes within the tree. The first item corresponds to the topmost node within the tree. If the topmost node has children, the second item of the collection corresponds to the first child or the top node, etc. Each node is represented by the TTreeNode object that provides access to its own children via the Item property.

At runtime, you can use the Items property either to create the structure of the tree or to access individual nodes. Tree creation can be performed using methods of the TTreeNodes class. The most commonly used methods are the Add and AddChild. Please refer to the TTreeNodes method list for more information. Individual items can be accessed to modify their settings. For instance, you can change the expanded state of a node, its caption text, etc. See the TTreeNode class description for a complete list of available settings.

A common task you might encounter when using a tree view control is to traverse through all nodes. This can be performed using the following procedure.

var ACurrentNode: TTreeNode;
begin
  ACurrentNode := cxTreeView1.Items[0];
  while ACurrentNode <> nil do
  begin
    // perform the desired operations on the current node here
    // ...
    ACurrentNode := ACurrentNode.GetNext;
  end;
end;

The code uses the GetNext method of the TTreeNode class to obtain the next node within the tree (child nodes are also visited). Please refer to the TTreeNode class description for details on methods used to navigate through nodes.

See Also