An expandable tree.

Syntax

[<oRef> =] new TreeView(<container> [,<name expC>])

<oRef>

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

<container>

The container—typically a Form object—to which you’re binding the TreeView object.

<name expC>

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

Properties

The following tables list the properties, events, and methods of interest in the TreeView class.

Property

Default

Description

allowDrop

false

Whether dragged objects can be dropped on the TreeView

allowEditLabels

true

Whether the text labels of the tree items are editable

allowEditTree

true

Whether items can be added or deleted from the tree

anchor

0 – None

How the TreeView object is anchored in its container (0=None, 1=Bottom, 2=Top, 3=Left, 4=Right, 5=Center, 6=Container)

baseClassName

TREEVIEW

Identifies the object as an instance of the TreeView class

checkBoxes

true

Whether each tree item has a checkbox

checkedImage

 

The image to display when a tree item is checked instead of a checked check box

className

(TREEVIEW)

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

colorNormal

WindowText
/Window

The color of the text labels and background

disablePopup

false

Whether the tree view’s popup menu is disabled

firstChild

 

The first child tree item

firstVisibleChild

 

The first TreeItem that is visible in the TreeView area

hasButtons

true

Whether + and - icons are displayed for TreeItems that have children

hasLines

true

Whether lines are drawn between TreeItems

image

 

Default image displayed between checkbox and text label when a TreeItem does not have focus

imageScaleToFont

true

Whether TreeItem images automatically scale to match the text label font height

imageSize

 

The height of TreeItem images in pixels

indent

 

The horizontal indent, in pixels, for each level of TreeItems

linesAtRoot

true

Whether a line connects the TreeItems at the first level

selected

 

The currently selected TreeItem

selectedImage

 

Default image displayed between CheckBox and TextLabel when a TreeItem has focus

showSelAlways

true

Whether to highlight the selected item in the tree even when the TreeView does not have focus

toolTips

true

Whether to display TextLabels as tooltips if they are too long to display fully in the TreeView area as the mouse passes over them

trackSelect

true

Whether to highlight and underline TreeItems as the mouse passes over them

uncheckedImage

 

The image to display when a TreeItem is not checked instead of an empty check box

 

Event

Parameters

Description

canChange

 

Before selection moves to another TreeItem; return value determines if selection can leave current TreeItem

canEditLabel

 

When attempting to edit text label; return value determines whether editing is allowed

canExpand

<oItem>

When attempting to expand or collapse a TreeItem; return value determines whether expand/collapse occurs

onChange

 

After the selection moves to another TreeItem

onCheckBoxClick

 

After a checkbox in a TreeItem is clicked

onDragEnter

<left expN>
<top expN>
<type expC>
<name expC>

When the mouse enters the TreeView display area during a Drag&Drop operation

onDragLeave

 

When the mouse leaves the TreeView display area without having dropped an object

onDragOver

<left expN>
<top expN>
<type expC>
<name expC>

While the mouse drags an object over the TreeView display area during a Drag&Drop operation

onDrop

<left expN>
<top expN>
<type expC>
<name expC>

 

When the mouse button is released over the TreeView display area during a Drag&Drop operation

onEditLabel

<text expC>

After the TextLabel in a TreeItem is edited; may optionally return a different label value to save

onExpand

<oItem>

After a TreeItem is expanded or collapsed

 

Method

Parameters

Description

count( )

 

Returns the total number of TreeItems in the tree

getItemByPos( )

<col expN>
<row expN>

Returns an object reference to a TreeItem object located at a specified position

loadChildren( )

<filename expC>

Loads and instantiates child TreeItems from a text file

releaseAllChildren( )

 

Deletes all TreeItems in the tree

sortChildren( )

 

Sorts child TreeItems

streamChildren( )

<filename expC>

Streams child TreeItems out to a text file

visibleCount( )

 

Returns the number of TreeItems visible in the tree view area

 

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

Property

 

Event

 

Method

before
borderStyle

dragEffect

enabled

fontBold

fontItalic

fontName

fontSize

fontStrikeout

fontUnderline

form

height

helpFile

helpId

hWnd
id

left

mousePointer

name

pageno

parent

printable

statusMessage

systemTheme
speedTip

tabStop

top

visible

width

onDesignOpen
onDragBegin

onGotFocus

onHelp

onLeftDblClick

onLeftMouseDown

onLeftMouseUp

onLostFocus

onMiddleDblClick
onMiddleMouseDown

onMiddleMouseUp

onMouseMove

onOpen

onRightDblClick

onRightMouseDown

onRightMouseUp

drag( )
move( )

release( )

setFocus( )

Description

A TreeView displays a collapsible multi-level tree. There are four ways to create the tree:

Explicitly add items with code, like the code generated by the Form Designer.

Interactively through the TreeView’s runtime user interface (right-clicking or pressing certain keys).

Data-driven code that reads a table and dynamically creates the tree items.

Use the TreeView's loadChildren( ) method to add items previously saved to a text file using streamChildren( ).

The TreeView object acts as the root of the tree. It contains the first level of TreeItem objects, which can contain their own TreeItem objects, thus forming a tree.

Unlike the deeper levels of the tree, you cannot collapse the first level of a tree. Therefore, you may want to use only one item at the first level of the tree to make the entire tree collapsible.