|
|
|
|
|
- Overview
- Principle
- Implementation
- Defining an identifier for managing the duplicates
- Handling an element via its identifier
- Finding out the identifier of an element
Managing duplicates in the TreeView controls
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. 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. 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:
| | TreeAdd | Adds a "leaf" element (and all necessary nodes) into a TreeView control. | TreeInsert | Inserts a leaf into a TreeView control at a specific position. | TreeModify | Modifies 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:
| | TreeListItem | Lists the "children" of a node and the "child" elements of these "children" in a TreeView control. | TreePosition | Displays a TreeView control from a specified element (node or leaf) or returns the name of the first element displayed in a TreeView control. | TreeSelect | Returns the full path of the selected element in a TreeView control. |
Related Examples:
|
Unit examples (WINDEV): The TreeView control
[ + ] Using the TreeView control via the WLanguage Tree functions.
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|