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

# TCustomTreeView

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

TCustomTreeView - ancestor class for TTreeView

## Declaration

Source position: comctrls.pp line 2195

`type TCustomTreeView = class(TCustomControl)`
`protected`
`FChangeTimer: TTimer;` |  | FChangeTimer - local variable to act as timer for changes
`FEditor: TEdit;`
`procedure WSRegisterClass; override;` |  | WSRegisterClass - Register this Class for the current Widget Set
`procedure EditorEditingDone(); virtual;`
`procedure EditorKeyDown(); virtual;`
`procedure BeginAutoDrag; override;` |  | Start the AutoDrag process
`procedure BeginEditing;`
`function DoDragMsg(); override;` |  | DoDragMsg generates system message to indicate object and position for dragging and returns Result of action
`function CanChange(); virtual;` |  | CanChange - returns True if a given TreeNode can be changed
`function CanCollapse(); virtual;` |  | CanCollapse returns True if a given TreeNode is able to be collapsed
`function CanEdit(); virtual;` |  | CanEdit - returns True if a Given TreeNode is allowed to be edited
`function CanExpand(); virtual;` |  | CanExpand - returns True if the specified TreeNode can be expanded
`function CreateNode; virtual;` |  | CreateNode - creates a new node in a TreeView and returns its content
`function CustomDraw(); virtual;` |  | CustomDraw - returns True if Custom Drawing is proceeding in the specified Rectangle
`function CustomDrawItem(); virtual;` |  | CustomDrawItem - returns True if Custom Image drawing is proceeding at the specified TreeNode
`function GetDragImages; override;` |  | Get the list of Images to be dragged - returned as a list
`function GetMaxLvl;` |  | GetMaxLvl - returns the maximum level of branching of the tree structure
`function GetMaxScrollLeft;` |  | GetMaxScrollLeft - returns maximal extent of scrolling to the left
`function GetMaxScrollTop;` |  | GetMaxScrollTop - returns the maximal extent of scrolling upwards
`function GetNodeAtInternalY();` |  | GetNodeAtInternalY - returns the node at the specified internal (ie relative) Y coordinate
`function GetNodeAtY();` |  | GetNodeAtY - returns the node at the specified (absolute) Y coordinate
`function GetNodeDrawAreaHeight;` |  | GetNodeDrawAreaHeight - returns the height for the area in which node is drawn
`function GetNodeDrawAreaWidth;` |  | GetNodeDrawAreaWidth - returns the width for the area in which node is drawn
`function IsCustomDrawn();` |  | IsCustomDrawn - returns True if the specified target node is custom drawn
`function IsNodeVisible();` |  | IsNodeVisible - returns True if the specified node is visible
`function IsNodeHeightFullVisible();` |  | IsNodeHeightFullVisible - returns True if the full height of the specified node is visible in the current view
`function IsInsertMarkVisible; virtual;` |  | IsInsertMarkVisible - returns True if an Insert mark is visible
`procedure Change(); virtual;` |  | Change - software emulation of the OnChange event
`procedure Collapse(); virtual;` |  | Collapse - software emulation of the OnCollapsed event
`procedure CreateParams(); override;` |  | CreateParams - create parameters for this windowed class
`procedure CreateWnd; override;` |  | CreateWnd - Creates the Window
`procedure Delete(); virtual;` |  | Delete - remove the specified node from the tree structure (software emulation of the OnDeletion event)
`procedure DestroyWnd; override;` |  | DestroyWnd - destroy the window for this control
`procedure DoEndDrag(); override;` |  | End the dragging process
`function DoMouseWheel(); override;` |  | DoMouseWheel - performs the action to deal with a movement of the mouse wheel; returns True if handled
`procedure DoPaint; virtual;` |  | DoPaint - perform the actual painting
`procedure DoPaintNode(); virtual;` |  | DoPaintNode - perform the actual painting of the specified node
`procedure DoStartDrag(); override;` |  | DoStartDrag - start performing the drag
`procedure DragOver(); override;` |  | Drag the control over the source; Accept determines if the dragged object will be accepted
`procedure EndEditing();` |  | EndEditing - finish editing
`procedure EnsureNodeIsVisible();` |  | EnsureNodeIsVisible - method to make sure specified node is visible
`procedure Expand(); virtual;` |  | Expand the specified node
`procedure GetImageIndex(); virtual;` |  | GetImageIndex - returns the index of the image associated with the specified node
`procedure GetSelectedIndex(); virtual;` |  | GetSelectedIndex - returns the index of the selected node
`procedure InitializeWnd; override;` |  | InitializeWnd - initialise the window for this control
`procedure KeyDown(); override;` |  | KeyDown - emulate the action of pressing the specified key (makes OnKeyDown respond)
`procedure Loaded; override;` |  | Loaded makes a number of checks, using client size if specified, and copying appropriate flags, fonts, text etc, makes list of child controls to notify them of any changes, then calls inherited Loaded
`procedure MouseDown(); override;` |  | MouseDown - a procedure that allows the programmer to simulate a mouse button being down over the control, and initiates the same Action as that associated with the OnMouseDown event
`procedure MouseMove(); override;` |  | MouseMove - a procedure that allows the programmer to simulate a mouse being moved over the control, and initiates the same Action as that associated with the OnMouseMove event
`procedure MouseUp(); override;` |  | MouseUp - a procedure that allows the programmer to simulate a mouse button being Up over the control, and initiates the same Action as that associated with the OnMouseUp event
`procedure Notification(); override;` |  | Notification - calls inherited Notification, then takes action depending on Operation
`procedure Paint; override;` |  | The default paint handler for the class
`procedure SetDragMode(); override;` |  | SetDragMode - specify the mode for dragging
`procedure SetOptions();` |  | SetOptions - specifies the options for the TreeView
`procedure UpdateDefaultItemHeight; virtual;` |  | UpdateDefaultItemHeight - brings the value of the default item height up-to-date
`procedure WndProc(); override;` |  | WndProc - message handler for the procedure of this window
`procedure UpdateInsertMark(); virtual;` |  | UpdateInsertMark - see if there is an insert mark at X,Y and put one in if necessary
`procedure DoSelectionChanged; virtual;` |  | DoSelectionChanged - perform the code required for a change in selection
`procedure WMHScroll(); message;` |  | WMHScroll - LCL Message for horizontal scroll
`procedure WMVScroll(); message;` |  | WMVScroll - LCL Message for Vertical scroll
`procedure WMLButtonDown(); message;` |  | Protected messages to system - when left mouse button is down
`procedure WMNotify(); message;` |  | WMNotify - LCL Notify message
`procedure Resize; override;` |  | Checks for changes and calls DoOnResize
`property AutoExpand: Boolean; [rw]` |  | AutoExpand - if True, the tree structure is automatically expanded when a node is selected
`property BorderStyle;`
`property HideSelection: Boolean; [rw]` |  | HideSelection - if True, the selected part of the tree is to be hidden
`property HotTrack: Boolean; [rw]` |  | HotTrack - the property whereby the item under the mouse pointer becomes emphasised
`property Images: TCustomImageList; [rw]` |  | Images - the ImageList to be used in association with the list of TreeNodes
`property Indent: Integer; [rw]` |  | Indent - the amount by which each successive level of branching is to be indented in the tree structure
`property Items: TTreeNodes; [rw]` |  | Items - the collection of TreeNodes that comprise the TreeView
`property OnAdvancedCustomDraw: TTVAdvancedCustomDrawEvent; [rw]` |  | OnAdvancedCustomDraw - event handler for advanced custom drawing
`property OnAdvancedCustomDrawItem: TTVAdvancedCustomDrawItemEvent; [rw]` |  | OnAdvancedCustomDrawItem - event handleer for advanced custom drawing item
`property OnChange: TTVChangedEvent; [rw]` |  | OnChange - specialised event handler for a change in the TreeView
`property OnChanging: TTVChangingEvent; [rw]` |  | OnChanging - specialised event handler while TreeView is being changed
`property OnCollapsed: TTVExpandedEvent; [rw]` |  | OnCollapsed - specialised event handler when part of the tree is collapsed
`property OnCollapsing: TTVCollapsingEvent; [rw]` |  | OnCollapsing - specialised event handler while part of the tree is being collapsed
`property OnCompare: TTVCompareEvent; [rw]` |  | OnCompare - specialised event handler for comparisons within the TreeView
`property OnCustomCreateItem: TTVCustomCreateNodeEvent; [rw]` |  | OnCustomCreateItem - event handler for custom item creation
`property OnCustomDraw: TTVCustomDrawEvent; [rw]` |  | OnCustomDraw - event handler for custom drawing
`property OnCustomDrawItem: TTVCustomDrawItemEvent; [rw]` |  | OnCustomDrawItem - event handler for custom drawing item
`property OnDeletion: TTVExpandedEvent; [rw]` |  | OnDeletion - specialised event handler for deletion of node(s) from the tree
`property OnEdited: TTVEditedEvent; [rw]` |  | OnEdited - specialised event handler when the TreeView has been edited
`property OnEditing: TTVEditingEvent; [rw]` |  | OnEditing - specialised event handler while a TreeView is being edited
`property OnExpanded: TTVExpandedEvent; [rw]` |  | OnExpanded - specialised event handler when a TreeView has been expanded
`property OnExpanding: TTVExpandingEvent; [rw]` |  | OnExpanding - specialised event handler while a TreeView is being expanded
`property OnGetImageIndex: TTVExpandedEvent; [rw]` |  | OnGetImageIndex - event handler for finding the index of an image
`property OnGetSelectedIndex: TTVExpandedEvent; [rw]` |  | OnGetSelectedIndex - event handler for finding index of selected item
`property OnSelectionChanged: TNotifyEvent; [rw]` |  | OnSelectionChanged - event handler for a change in the selection
`property ReadOnly: Boolean; [rw]` |  | ReadOnly - if True, the TreeView can only be observed, and not Written to or changed. Default False
`property RightClickSelect: Boolean; [rw]` |  | RightClickSelect - if True, a Right Click selects an Item. Default False
`property RowSelect: Boolean; [rw]` |  | RowSelect - if True, a row is selected
`property ScrolledLeft: Integer; [rw]` |  | ScrolledLeft - the position of the tree when fully scrolled to the left
`property ScrolledTop: Integer; [rw]` |  | ScrolledTop - th eposition of th etree when fully scrolled to the top
`property ShowButtons: Boolean; [rw]` |  | ShowButtons - if True, buttons are displayed
`property ShowLines: Boolean; [rw]` |  | ShowLines - show the connecting lines of the tree structure
`property ShowRoot: Boolean; [rw]` |  | ShowRoot - if True, the root of the tree structure is displayed
`property ShowSeparators: Boolean; [rw]` |  | ShowSeparators - if True, separators are shown between items
`property SortType: TSortType; [rw]` |  | SortType - the way the items are to be sorted: None, by Data, by Text or Both
`property StateImages: TCustomImageList; [rw]` |  | StateImages - the list of images to denote state of the tree (expanded, contracted etc)
`property ToolTips: Boolean; [rw]` |  | ToolTips - if True (default), pop-up tool tips are to be shown
`public`
`constructor Create(); override;` |  | Create - constructor for TCustomTreeView: calls inherited Create then sets defaults for style, size, etc
`destructor Destroy; override;` |  | Destroy - destructor for TCustomTreeView: frees images, nodes and links, then calls inherited Destroy
`function AlphaSort;` |  | If True, sort alphabetically
`procedure ConsistencyCheck;` |  | ConsistencyCheck - check that indexes of treenodes match those of images etc
`function CustomSort();` |  | CustomSort - if True, an external sorting method specified by SortProc is to be used
`function DefaultTreeViewSort();` |  | DefaultTreeViewSort - returns result of string comparison between names of Node1 and Node2
`procedure EraseBackground(); override;` |  | EraseBackground - remove all material from the background
`function GetHitTestInfoAt();` |  | GetHitTestInfoAt - returns the result of a hit test at the point (X, Y)
`function GetNodeAt();` |  | GetNodeAt - returns the TreeNode at position (X. Y)
`procedure GetInsertMarkAt();` |  | GetInsertMarkAt - find if there is an insert mark at the specified coordinates
`procedure SetInsertMark();` |  | SetInsertMark - place an Insert mark at the specified node in the tree
`procedure SetInsertMarkAt(); virtual;` |  | SetInsertMarkAt - place an insert mark at the specified coordinates
`procedure Invalidate; override;` |  | Render this control non-valid
`function IsEditing;` |  | IsEditing - returns True if editing is in progress
`procedure BeginUpdate;` |  | BeginUpdate - start the update of the display
`procedure EndUpdate;` |  | EndUpdate finishes updating the display
`procedure FullCollapse;` |  | FullCollapse - method to collapse the treeview fully, ie show just the root
`procedure FullExpand;` |  | FullExpand - method to expand the treeview fully, and show all the branches
`procedure LoadFromFile();` |  | LoadFromFile - load the data from the specified file
`procedure LoadFromStream();` |  | LoadFromStream - load data from the specified stream
`procedure SaveToFile();` |  | SaveToFile - saves the data to the specified file
`procedure SaveToStream();` |  | SaveToStream - save the data to the specified stream
`procedure WriteDebugReport();` |  | WriteDebugReport - used for debugging
`procedure LockSelectionChangeEvent;` |  | LockSelectionChangeEvent - if the selection has changed, lock its status
`procedure UnlockSelectionChangeEvent;` |  | UnlockSelectionChangeEvent - unlock a selection to allow it to be changed
`function GetFirstMultiSelected;` |  | GetFirstMultiSelected - returns the first node from a multiple selection
`function SelectionVisible;` |  | SelectionVisible - returns True if a selection is visible
`procedure MakeSelectionVisible;` |  | MakeSelectionVisible - method for making a selection visible
`property BackgroundColor: TColor; [rw]` |  | BackgroundColor for the treeview
`property BorderWidth;` |  | Property to determine width of the window's border
`property BottomItem: TTreeNode; [rw]` |  | BottomItem - the last item on the list
`property DefaultItemHeight: Integer; [rw]` |  | DefaultItemHeight - default height for items on the list
`property DropTarget: TTreeNode; [rw]` |  | DropTarget - the target node for dropping a dragged item
`property ExpandSignType: TTreeViewExpandSignType; [rw]` |  | ExpandSignType - the symbols to denote whether a list is expanded or collapsed; default is plus or minus
`property InsertMarkNode: TTreeNode; [rw]` |  | InsertMarkNode - place a marker on the specified node
`property InsertMarkType: TTreeViewInsertMarkType; [rw]` |  | InsertMarkType - the type of marker to be inserted
`property KeepCollapsedNodes: Boolean; [rw]` |  | KeepCollapsedNodes - if True, the collapsed nodes are to be retained
`property Options: TTreeViewOptions; [rw]` |  | The set of Options for displaying the tree view
`property ScrollBars: TScrollStyle; [rw]` |  | ScrollBars - the style of scroll bars for the treeview display
`property Selected: TTreeNode; [rw]` |  | The Selected tree nodes
`property SelectionColor: TColor; [rw]` |  | SelectionColor - the colour to be used for the selected nodes, to distinguish them from the others
`property SeparatorColor: TColor; [rw]` |  | SeparatorColor - the colour to be used for separators
`property TopItem: TTreeNode; [rw]` |  | TopItem - the first node on the list
`property TreeLineColor: TColor; [rw]` |  | TreeLineColor - the colour to be used for the lines showing the tree structure
`property TreeLinePenStyle: TPenStyle; [rw]` |  | TreeLinePenStyle - the pen style for drawing lines on the tree
`property ExpandSignColor: TColor; [rw]` |  | ExpandSignColor - the colour to be used for the expand/collapse symbols
`published`
`property TabStop;` |  | Is the control in the sequence of controls accessed by successive presses of the Tab key?
`end;`

## Inheritance

`TCustomTreeView` |  | TCustomTreeView - ancestor class for TTreeView
`TCustomControl`
?
`TObject`

## Description

TCustomTreeView - ancestor class for TTreeView, which displays a collection of items in a hierarchical tree form. This class defines many properties which are inherited by children classes, including loading the data from files or streams, saving to files or streams, updating, sorting alphabetically, editing, making visible or invisible, expanding or collapsing the tree display, and many more.

The latest version of this document can be found at lazarus-ccr.sourceforge.net.