ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / TreeView control
  • Overview
  • Handling the elements of a TreeView control directly
  • WLanguage functions
  • Direct operation
  • Initializing an element in a TreeView control
  • Initializing an element
  • Associating a tooltip with an element
  • Selecting an element in a TreeView control
  • Selecting an element at row
  • Positioning on the last element of the TreeView control
  • Retrieving the element selected in the TreeView control
  • WLanguage properties associated with the elements of a TreeView control
  • Using properties on an element of a TreeView control
  • Examples
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
This help page explains how to handle the elements of a TreeView control either directly or via the WLanguage functions.
You can:
WEBDEV - Browser code This version can only be used to retrieve the element selected in a Treeview control.
Handling the elements of a TreeView control directly

WLanguage functions

In the WLanguage functions for managing TreeView controls, the element of the TreeView control is handled via its full path (from the root of the TreeView control). This path has the following format:
"<Root name>" + TAB + ["<Name of 1st node>" + TAB + ...
["<Name of 2nd node>" + TAB + [...]]]"<Leaf name>"
The different elements that constitute the path of characters strings are separated by TAB characters.
WINDEVWEBDEV - Server codeJavaAjax

Direct operation

To manipulate an element of a TreeView control directly (with the WLanguage properties for example), two notations are available:
  • Operation performed via the index of the element:
    All you have to do is use the following notation: <TreeView control> [ <Element index>].
    Caution: The specified indices only take the visible elements into account.
    Example: Modifying the color of the 5th element displayed in a TreeView control:
    TREE_MyTreeView[5].Color = LightRed
  • Operation performed via the full path of the element:
    All you have to do is use the following notation: <TreeView control> [ <Element path>].
    The path of the element is a character string in the following format:
    "<Root name>" + TAB + ["<Name of 1st node>" + TAB + ...
    ["<Name of 2nd node>" + TAB + [...]]]"<Leaf name>"
    Example: Modifying the color of the "Pineapple" element.
    TREE_MyTreeView["Recipe" + TAB + "Dessert" + TAB + "Pineapple"].Color = LightRed
Remark: You also have the ability to use the following notation to identify the current element in a TreeView control:
MySelf[TreeSelect(MySelf)]
Initializing an element in a TreeView control
WINDEVWEBDEV - Server codeJavaAjax

Initializing an element

To initialize an element found in a TreeView control, use TreeAdd.
During this addition, you can:
WINDEVWEBDEV - Server codeJavaAjax

Associating a tooltip with an element

To associate a tooltip with an element in a Treeview control, you can use:
If the text of the element tooltip is not specified, the text displayed will be the text of the tooltip for the TreeView control (if it exists).
Reminder: By default, the tooltip associated with the different controls is displayed. To specify whether the tooltips must be displayed or not, use ShowToolTip.
Selecting an element in a TreeView control
WINDEVWEBDEV - Server codeJavaAjax

Selecting an element at row <Index>

To select the element at row <Index>, use:
  • the direct assignment:
    <TreeView control> = Index

    If the row is displayed in the TreeView control, the corresponding element is selected.
  • the TreeSelectPlus function:
    TreeSelectPlus(<TreeView control>, <Full element name>)
WINDEVJavaAjax

Positioning on the last element of the TreeView control

To set the position on the last element of the TreeView control, use the Count property:
<TreeView control> = <TreeView control>.Count
Retrieving the element selected in the TreeView control
To retrieve:
  • the index of the selected element, use the direct reading of the element:
    Index = <TreeView control>
    WEBDEV - Server codeWEBDEV - Browser code This feature is not available in WEBDEV.
  • the full path of the selected element, use TreeSelect:
    <Path> = TreeSelect(<TreeView control>)
    WEBDEV - Browser code TreeSelect is available in Browser code.
  • the identifier of the selected element, use TreeIdentifier.
    WEBDEV - Browser code TreeIdentifier is not available in Browser code.
WLanguage properties associated with the elements of a TreeView control
WINDEVWEBDEV - Server codeJavaAjax

Using properties on an element of a TreeView control

Several WLanguage properties can be used on the elements of a TreeView control.
For a complete list of WLanguage properties that can be used on an element of a TreeView control, see Properties associated with a row of a TreeView control.
WINDEVWEBDEV - Server codeJavaAjax

Examples

Example: How to modify the color of an element in a TreeView control:
TREE_MyTreeView[5].Color = LightRed

Example: How to modify the size of the font used for an element of a TreeView control:
TREE_MyTreeView["Recipe" + TAB + "Dessert" + TAB + "Pineapple"].FontSize = 14
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/12/2023

Send a report | Local help