ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / How to proceed? / Programming
  • TreeAdd function: Adding an element at any position
  • Code samples
  • TreeInsert function: Inserting an element at a specific position
  • Code example
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
A TreeView control is used to represent data hierarchically (on several levels). For example, a TreeView control can represent products groupd by Family then Sub-family.
To populate a TreeView control programmatically, you must use:
TreeAdd function: Adding an element at any position
TreeAdd is used to add an element into a TreeView control. An element is made of:
  • Root: represents the first level of the element
  • Branch(es): represents the intermediate level(s)
  • Leaf: represents the data to classify
An element is represented in the following format:
Root + TAB + Branch 1 + TAB + Branch 2 + TAB + ... + TAB + Leaf
The syntax of TreeAdd is as follows:
TreeAdd(<TreeView name>, <Element>, <Collapsed image>, <Expanded image>, <Identifier>)
For more details, see the help page on the TreeAdd function.

Code samples

  • Fill through programming:
    TreeAdd(TREE_City, "France")
    TreeAdd(TREE_City, "Italy")
    TreeAdd(TREE_City, "France" + TAB + "Paris")
    TreeAdd(TREE_City, "France" + TAB + "Marseille")
    TreeAdd(TREE_City, "France" + TAB + "Lyon")
    TreeAdd(TREE_City, "France" + TAB + "Montpellier")
    TreeAdd(TREE_City, "Italy" + TAB + "Rome")
    TreeAdd(TREE_City, "Italy" + TAB + "Pisa")
    TreeAdd(TREE_City, "Italy" + TAB + "Milan")
    TreeAdd(TREE_City, "Spain" + TAB + "Barcelona")
    TreeAdd(TREE_City, "Spain" + TAB + "Madrid")
    TreeAdd(TREE_City, "Spain" + TAB + "Valence")
  • Fill from a data file:
    // Read families
    FOR EACH Family
    // Add the family into the treeview (level 1: root)
    TreeAdd(TREE_Products, Family.Caption)
     
    // Read sub-families
    FOR EACH SubFam WITH FamilyID = Family.FamilyID
    // Add the sub-family (level 2: branch 1)
    TreeAdd(TREE_Products, Family.Caption + TAB + SubFam.Caption)
     
    // Read products
    FOR EACH PRODUCT WITH SubsFamID = SubFam.SubFamID
    // Add the product: (leaf)
    TreeAdd(TREE_Products,
    Family.Caption + TAB + SubFam.Caption + TAB + PRODUCT.ProdCap)
    END
    END
    END
TreeInsert function: Inserting an element at a specific position
TreeInsert is used to insert a leaf in relation to another leaf (brother leaf).
The syntax of TreeInsert is as follows:
TreeInsert(<TreeView name>, <Brother leaf>, <New leaf>,
<Collapsed image>, <Expanded image>, <Identifier>)
For more details, see the help page on the TreeInsert function.

Code example

TreeAdd(TREE_City, "France")
TreeAdd(TREE_City, "Italy")
TreeAdd(TREE_City, "France" + TAB + "Paris")
TreeAdd(TREE_City, "France" + TAB + "Marseille")
TreeAdd(TREE_City, "France" + TAB + "Lyon")
 
// Inserts the cities of Montpellier and Bordeaux on the same level as Lyon
TreeInsert(TREE_City, "France" + TAB + "Lyon", "Montpellier")
TreeInsert(TREE_City, "France" + TAB + "Lyon", "Bordeaux")
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 10/27/2022

Send a report | Local help