Delphi - Tree Panel

Microsoft provides a TreeViewer - in Delphi, a wrapper component is available via Win32 / TreeView. Unfortunately, neither Windows nor Delphi provides a good tutorial on how, or why, to use this ... perhaps this page will help.

Overview | Properties | Methods | Examples in the Delphi Help | Images | Simple Tutorial | | Click or Double Click a Node


Overview

The TreeView component is used to display an hierarchical list of nodes - similar to the directory view in Windows Explorer. Each node is an instance of TTreeNode. TTreeView.Items (an instance of TTreeNodes) manages the node collection.

In a basic tree list, the nodes are just text. It is also possible to have the nodes associated with objects or records (ie, they can store a pointer).

Each node has 2 index numbers - one absolute and one relative to its parent node. When new nodes are added, or existing nodes are deleted, the indices of the other nodes change accordingly.


Basic Properties


Basic Methods


Examples in the Delphi Help

There aren't many examples in the Delphi 5 help - these are the useful ones that I know about.


Images

The TreeView component is capable of displaying zero, one, or two images to the left of any node. Based on trial and error (there is no help) the images should be 16x16 *.bmp files - the size of the *.bmp files in

When ImageIndex and SelectedIndex contain different values, the image is automatically changed when you click on (select) that node. (For example, consider the open and closed directory folders in Windows Explorer.)

The State image is intended to show both states of a check box, radio button, and similar state indicators ... however, you may use it for anything you like.

Both Images and StateImages specify (point to) a list of images - they may be the same or different. If neither one is set, then no images are displayed.

Specific images are selected via the indices

The first image in the associated list is zero (0), minus one (-1) hides the image.


Simple Tutorial

Test the form


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Languages / Delphi / TreePanel.html