PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • TreeAdd function: Adding an element at any position
  • Code samples
  • TreeInsert function: Inserting an element at a specific position
  • Code sample
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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 fill a TreeView control by programming, 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>)
See the help page about TreeAdd for more details.

Code samples

  • Fill by 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>)
See the help page about TreeInsert for more details.

Code sample

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 required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment