ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / TreeView control
  • Overview
  • Principle
  • Implementation
  • Defining an identifier for managing the duplicates
  • Handling an element via its identifier
  • Finding out the identifier of an element
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
WINDEV, WINDEV Mobile and WEBDEV allow you to add duplicates into the elements of a TreeView control. The mechanism for managing the duplicates in the TreeView controls allows you to easily handle these duplicates.
Principle
The management of duplicates in the TreeView controls is based on the management of the identifiers for each treeview element.
Indeed, when adding, inserting or modifying an element in a TreeView control, you have the ability to specify an identifier for the element used. This identifier (defined by the developer) will be used to identify the duplicate handled by the user.
The principle is straightforward: all you have to do is use a different identifier for each duplicate. This identifier will be retrieved by the functions for treeview management and it will be used to identify the duplicated handled.
Implementation

Defining an identifier for managing the duplicates

The definition of an identifier is performed when adding or modifying an element to a Treeview control.
To associate an identifier with an element found in a TreeView control, this identifier must be specified in the following programming functions:
TreeAddAdds a "leaf" element (and all necessary nodes) into a TreeView control.
TreeInsertInserts a leaf into a TreeView control at a specific position.
TreeModifyModifies an element (node or leaf) in a TreeView control.
Example:
ResultTreeView is boolean
ResultTreeView = TreeAdd(TREE_TreeView1, "Root" + TAB + "Node" + TAB + "Leaf", ...
tvDefault, tvDefault, "Leaf ID")
ResultTreeView = TreeAdd(TREE_TreeView1, "Root" + TAB + "Node" + TAB + "Leaf", ...
tvDefault, tvDefault, "ID of Leaf 2", tvAcceptDuplicate)

Handling an element via its identifier

To handle a duplicate element, its identifier must be known and specified.
to handle an element whose path is known, each element of the path must be filled (if necessary) with its identifier using TreeID.
Example: To add a leaf to the "Root"+TAB+"Node"+TAB+"Leaf" element, whose identifier is "Leaf ID", use the following syntax:
ResultTreeView = TreeAdd(TREE_TreeView1, "Root" + TAB + "Node" + TAB + "Leaf" + ...
TreeID("Leaf ID") + TAB + "My Element", tvDefault, tvDefault, "My Element 1")
TreeID can also be used with the following syntax: <TreeView name> [ <Element path>].
For example:
TREE_TreeView1["Root" + TAB + "Node" + TAB + "Leaf" + TreeID("Leaf ID") + ...
TAB + "My Element"]..Color = LightRed

Finding out the identifier of an element

To find out the identifier of a treeview element, all you have to do is use TreeIdentifier.
When managing the duplicates, the identifier is an integral part of the path as it is used to identify the selected element.
Therefore, the WLanguage functions returning the path of an element (when selecting an element for example) can return:
  • the path of the element while ignoring the identifier.
  • the path of the element by including (if necessary) the identifier of each element found in the path.
The affected functions are as follows:
TreeListItemLists the "children" of a node and the "child" elements of these "children" in a TreeView control.
TreePositionDisplays a TreeView control from a specified element (node or leaf) or returns the name of the first element displayed in a TreeView control.
TreeSelectReturns the full path of the selected element in a TreeView control.
Related Examples:
The TreeView control Unit examples (WINDEV): The TreeView control
[ + ] Using the TreeView control via the WLanguage Tree functions.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/03/2023

Send a report | Local help