TreeView Items Editor

From RAD Studio
Jump to: navigation, search

Go Up to Property Editors Index

Use the TreeView Items editor at design time to add items to a tree view component, delete items from a tree view component, or load images from disk into a tree view component. You can specify the text associated with individual tree view items, and set the image index, selected index, and state index for items.

To display the TreeView Items editor, add a TTreeView component to your Form Designer and then do any of the following:

  • Select the TTreeView object and double-click either:
    • The Items property value in the Object Inspector.
    • The name of the TreeView component (such as TreeView1) in the Structure Pane.
  • Right-click the TTreeView object and select Items Editor from the context menu.


Using the TreeView Items editor

The TreeView Items editor contains an Items group box with an Items list box, a New Item button, a New SubItem button, a Delete button, and a Load button. When you first add a tree view control to a form, the Items list box is empty, and the New SubItem and Delete buttons are disabled. When you enter or change item properties for a selected item, the Apply button is enabled so that you can activate changes immediately.


The TreeView Items editor also contains an Item Properties group box for setting the properties of the tree view item currently selected in the Items list box. The Item Properties group box contains a Text edit box, an Image Index edit box, a Selected Index edit box, and a State Index edit box.

Items group box

Create, load, and delete tree view items and subitems in the Items group box. To create a new item, click New Item. The default text for the item appears in the Items list box. Specify an item's properties, including its text, in the Items Properties group box.

To load a set of existing tree view items from disk, click Load. The file that is loaded must be formatted as follows:

  • Each item must be on a new line. If a line is empty, the corresponding tree view item will be empty (without any text).
  • Each subitem must be indented by one tab relative to the position of its parent.
  • No leading spaces are permitted before the item text.

When you create a new item, or select an existing item, the New SubItem button is enabled so that you can nest items within other items in the tree view. If the Items list box contains items, the Delete button is also enabled. To delete an item, select it in the Items list box and click Delete.

Item Properties group box

Set the properties for a selected item in the Item Properties group box. Enter text for the item in the Text edit box. As you enter the name, it changes in the Items list box.

  • To display an image to the left of an item that is not currently selected, specify the index number of the image in the Image Index edit box. To suppress image display, set Image Index to -1 (the default).
  • To display an image to the left of a selected item, specify the index number of the image in the Selected Index edit box. The index is zero-based. To suppress image display, set Selected Index to -1 (the default).
  • To display an additional image to the left of an item, specify the index number of the image in the State Index edit box. The index number represents an index into the StateImages property of the listview component. The index is zero-based. To suppress image display, set State Index to -1 (the default).
  • To display an image when an item is expanded, specify the index number of the image in the Expanded Index edit box. The index is zero-based.
  • To disable selecting an item, select the Enabled check box. The item can still be expanded when disabled.