An item in a TreeView.

Syntax

[<oRef> =] new TreeItem(<parent> [,<name expC>])

<oRef>

A variable or property—typically of <parent>—in which to store a reference to the newly created TreeItem object.

<parent>

The parent object—a TreeView object for top-level items, or another TreeItem—to which you’re binding the TreeItem object.

<name expC>

An optional name for the TreeItem object. If not specified, the TreeItem class will auto-generate a name for the object.

Properties

The following tables list the properties and methods of interest in the TreeItem class. (No particular events are associated with this class.)

Property

Default

Description

baseClassName

TREEITEM

Identifies the object as an instance of the TreeItem class

bold

false

Whether the text label is bold

checked

false

Whether the item is visually marked as checked

className

(TREEITEM)

Identifies the object as an instance of a custom class. When no custom class exists, defaults to baseClassName

expanded

false

Whether the item’s children are shown or hidden

firstChild

 

The first child tree item

handle

 

The Windows tree item handle (similar to hWnd)

image

 

Image displayed between checkbox and text label when item does not have focus

level

 

The tree level of the item

nextSibling

 

The next tree item with the same parent

noOfChildren

 

The number of child tree items

prevSibling

 

The previous tree item with the same parent

selectedImage

 

Image displayed between checkbox and text label when item has focus

text

 

The text label of the tree item

 

Method

Parameters

Description

ensureVisible( )

 

Expands the tree and scrolls the tree view if necessary to make the tree item visible

select( )

 

Makes the tree item the selected item in the tree

setAsFirstVisible( )

 

Expands the tree and scrolls the tree view if necessary to try to make the tree item the first (topmost) visible tree item

sortChildren( )

 

Sorts the child tree items

 

The following table lists the common properties, events, and methods of the TreeItem class:

Property

 

Event

 

Method

name
parent

 

beforeRelease

 

release( )

Description

Each item in a tree view can contain text, an icon image that can change when the item is selected, and a checkbox. You can replace the checkbox images with a different pair of images to represent any two-state condition.

A TreeItem object can contain other TreeItem objects as child objects in a subtree, which can be expanded or collapsed.