[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ComCtrls' (#lcl)

# TTreeNode

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Implements a tree node displayed in a TTreeView control.

## Declaration

Source position: comctrls.pp line 3007

`type TTreeNode = class(TPersistent)`
`protected`
`procedure Changed();` |  | Performs a change notification for the node with the specified reason.
`function GetOwner; override;` |  | Gets the owner of the object instance.
`public`
`constructor Create(); virtual;` |  | Constructor for the class instance.
`destructor Destroy; override;` |  | Destructor for the class instance.
`function AlphaSort;` |  | Sorts the top-level child nodes in Items.
`function Bottom;` |  | Gets the vertical coordinate for the bottom of the tree node.
`function BottomExpanded;` |  | Gets the bottom coordinate for the last visible, expanded child node in the subtree.
`function CustomSort();` |  | CustomSort - Sorts the child nodes using SortProc.
`function DefaultTreeViewSort();` |  | Default routine used to returns a numeric value with the sort order for the specified tree nodes.
`function DisplayExpandSignLeft;` |  | Returns the position for the left edge of the expand / collapse indicator.
`function DisplayExpandSignRect;` |  | Returns the coordinates for the rectangle within which the expand / collapse indicator is displayed.
`function DisplayExpandSignRight;` |  | Returns the position for the right edge of the expand / collapse indicator (accounting for the width of the icon, etc.).
`function DisplayIconLeft;` |  | Returns the horizontal position for the left edge of the icon displayed for the tree node.
`function DisplayRect();` |  | Returns the rectangle where the tree node is displayed on its TreeView control.
`function DisplayStateIconLeft;` |  | Returns the horizontal position for the left edge of the State icon on the tree node.
`function DisplayTextLeft;` |  | Returns the position for the left edge of the text on the tree node.
`function DisplayTextRight;` |  | Returns the horizontal position for the right edge of the Text on the tree node.
`function EditText;` |  | Edits the text for the node in the associated TreeView control.
`function FindNode();` |  | Gets the child tree node in Items with the specified text.
`function GetFirstChild;` |  | Gets the first child node in the Items property.
`function GetFirstSibling;` |  | Gets the first tree node at the same level in the tree.
`function GetFirstVisibleChild();` |  | Gets the tree node that is the first visible child node in the subtree.
`function GetHandle;` |  | Gets the value for the Handle property.
`function GetLastChild;` |  | Gets the last tree node that is a top-level child node in Items.
`function GetLastSibling;` |  | Gets the last node at the same level as the current node.
`function GetLastSubChild;` |  | Returns the last child node or its last descendent node.
`function GetLastVisibleChild();` |  | Gets the last child node in the subtree with its Visible property set to True.
`function GetNext;` |  | Gets the next node in the tree hierarchy.
`function GetNextChild();` |  | Returns the next child node for the parent node specified in AValue.
`function GetNextExpanded();` |  | Returns the next expanded tree node in the node hierarchy.
`function GetNextMultiSelected;` |  | Returns the next tree node which is included in a multi-selected range of nodes.
`function GetNextSibling;` |  | Returns the next node in the tree hierarchy at the same level as the current node.
`function GetNextSkipChildren;` |  | Gets the next sibling for the current tree node, or Nil when a sibling node does not exist.
`function GetNextVisible();` |  | Gets the next visible node child or sibling for the current node.
`function GetNextVisibleSibling();` |  | Gets the next visible node at the same level in the node tree.
`function GetParentNodeOfAbsoluteLevel();` |  | GetParentNodeOfAbsoluteLevel - returns the parent of all nodes at this absolute level.
`function GetPrev;` |  | Gets the previous node in the tree hierarchy.
`function GetPrevChild();` |  | Gets the previous child node starting at the specified child node.
`function GetPrevExpanded();` |  | Returns the previous expanded tree node in the node hierarchy.
`function GetPrevMultiSelected;` |  | GetPrevMultiSelected - returns the previous node in a multi-selection.
`function GetPrevSibling;` |  | GetPrevSibling - returns the previous node in the same level as the current node.
`function GetPrevVisible();` |  | Returns the previous visible (not hidden) tree node in the node hierarchy.
`function GetPrevVisibleSibling();` |  | Gets the previous visible sibling tree node for the current node.
`function GetTextPath;` |  | Gets the hierarchical path to the tree node in the tree view.
`function HasAsParent();` |  | Returns True if the specified node is a parent for the current node.
`function IndexOf();` |  | Get the index position for the specified child tree node.
`function IndexOfText();` |  | Returns the ordinal position for the last child node containing the specified Text.
`procedure Assign(); override;` |  | Implements object persistence for the TTreeNode type.
`procedure Collapse();` |  | Collapses the current tree node, and optionally collapses any descendent nodes.
`procedure ConsistencyCheck;` |  | Ensures that node references to or from the current tree node are valid and consistent.
`procedure Delete;` |  | Frees the current tree node when the Deleting property is not True.
`procedure DeleteChildren;` |  | Removes all child nodes and descendants in the tree structure.
`procedure EndEdit();` |  | Ends editing of the tree node in the associated tree view control.
`procedure Expand();` |  | Expands the current tree node, and optionally all descendent nodes.
`procedure ExpandParents;` |  | Expands all tree nodes which are an ancestor of the current node.
`procedure FreeAllNodeData;` |  | Frees the Pointer in Data, including any child nodes in Items.
`procedure MakeVisible;` |  | Forces the tree node to become visible.
`procedure MoveTo(); virtual;` |  | Relocates a node to the specified Destination node using the specified mode of attachment.
`procedure MultiSelectGroup;` |  | Adds the group of nodes between a selected node and the current node to a multi-selection range.
`procedure Update;` |  | Redraws the associated TreeView control if an update is not already in progress.
`procedure WriteDebugReport();` |  | WriteDebugReport - for debugging. If Recurse is True, report for all descendants as well.
`property AbsoluteIndex: Integer; [r]` |  | The absolute ordinal position for the node, regardless of its level or ancestry, in the tree node hierarchy.
`property Count: Integer; [r]` |  | The number of nodes which have the current node as the Parent node.
`property Cut: Boolean; [rw]` |  | Indicates if the tree node has been cut from the tree structure.
`property Data: Pointer; [rw]` |  | Pointer to the custom data for the node.
`property Deleting: Boolean; [r]` |  | True if the node has been marked for deletion in the associated tree view control.
`property DropTarget: Boolean; [rw]` |  | True if the node is a drop target in a drag and drop operation.
`property Expanded: Boolean; [rw]` |  | True if the node has been expanded, False when collapsed.
`property Focused: Boolean; [rw]` |  | True if the node has focus in the TreeView control.
`property Handle: TLCLHandle; [r]` |  | Handle for the tree view control which owns the TreeNodes container and the tree node.
`property HasChildren: Boolean; [rw]` |  | Indicates whether the tree node has child nodes.
`property Height: Integer; [rw]` |  | The height for the node including its text, images, and indicators.
`property ImageIndex: TImageIndex; [rw]` |  | Ordinal position for the image displayed for the node, or -1 when no image is assigned.
`property Index: Integer; [rw]` |  | Ordinal position for the node in its parent node.
`property IsFullHeightVisible: Boolean; [r]` |  | True if the entire node is visible in the display area for the associated TreeView control.
`property IsVisible: Boolean; [r]` |  | True if the node is visible.
`property Items []: TTreeNode; default; [rw]` |  | Provides indexed access to the child nodes for the current node.
`property Level: Integer; [r]` |  | The number of ancestor nodes for the current tree node.
`property MultiSelected: Boolean; [rw]` |  | Indicates whether the node is one of several nodes selected simultaneously (e.g. using the Shift or Ctrl key while selecting on a tree view control).
`property NodeEffect: TGraphicsDrawEffect; [rw]` |  | Graphic drawing effect applied to the node in the associated TreeView control.
`property OverlayIndex: Integer; [rw]` |  | Ordinal position for the overlay image used for the node.
`property Owner: TTreeNodes; [r]` |  | Owner of the tree node instance.
`property Parent: TTreeNode; [r]` |  | Parent node for the current tree node.
`property Selected: Boolean; [rw]` |  | True if the current node is selected in the tree view control.
`property SelectedIndex: Integer; [rw]` |  | Ordinal position for the image displayed when the tree node is Selected.
`property StateIndex: Integer; [rw]` |  | Ordinal position for the image displayed to represent the state for the tree node.
`property States: TNodeStates; [r]` |  | Contains active state flags for the tree node.
`property SubTreeCount: Integer; [r]` |  | The number of subtrees in the ancestor nodes for the class instance.
`property Text: string; [rw]` |  | Text displayed for the tree node.
`property Top: Integer; [r]` |  | Vertical coordinate for the top of the tree node.
`property TreeNodes: TTreeNodes; [r]` |  | The container where the tree node is stored, and the owner of the class instance.
`property TreeView: TCustomTreeView; [r]` |  | The tree view control where the node is displayed.
`property Visible: Boolean; [rw]` |  | True if the tree node is visible in the associated TreeView control.
`property Enabled: Boolean; [rw]` |  | Controls whether the tree node can be selected, and its visual appearance.
`end;`

## Inheritance

`TTreeNode` |  | Implements a tree node displayed in a TTreeView control.
`TPersistent`
?
`TObject`

## Description

A TTreeNode implements a node which is part a hierarchical tree structure displayed in a TTreeView control.

TTreeNode has properties with the content displayed for the tree node like: Text, Data, ImageIndex, and OverlayIndex. It has properties which indicate the state for the node on the tree view control like: Cut, Deleting, Expanded, Focused, IsVisible, Selected, MultiSelected, States, Visible, and Enabled. It also includes properties that represent its relationship and position in the hierarchical tree structure like: TreeView, Owner / TreeNodes, Parent, Items, Level, Index, and AbsoluteIndex.

Methods are provided to locate and navigate between the parent, sibling, and child nodes in the tree structure.

Tree nodes are normally created and maintained using the TTreeNodes container which is the Owner for the tree node.

An excellent tutorial for using TTreeView, TTreeNodes, and TTreeNode can be found at:

TTreeView Page on the Lazarus Wiki

## See also

How To Use Standard Controls |  | How to use StdCtrls, ComCtrls or ExtCtrls.