ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / How to proceed? / Programming
  • TreeAdd function: Add an element at any position
  • Code samples
  • TreeInsert function: Insert an element at a specific position
  • Code example
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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: Add 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)
  • Sheet: represents the data to be sorted
An element is represented in the following format:
Racine + TAB + Branche 1 + TAB + Branche 2 + TAB + ... + TAB + Feuille
The syntax of TreeAdd is as follows:
ArbreAjoute(<Nom Arbre>, <élément>, <image enroulée>, <image déroulée>, <identifiant>)
For more details, see the help page on the TreeAdd function.

Code samples

  • Fill through programming:
    TreeAdd(ARBRE_Ville, "France")
    TreeAdd(ARBRE_Ville, "Italie")
    TreeAdd(ARBRE_Ville, "France" + TAB + "Paris")
    TreeAdd(ARBRE_Ville, "France" + TAB + "Marseille")
    TreeAdd(ARBRE_Ville, "France" + TAB + "Lyon")
    TreeAdd(ARBRE_Ville, "France" + TAB + "Montpellier")
    TreeAdd(ARBRE_Ville, "Italie" + TAB + "Rome")
    TreeAdd(ARBRE_Ville, "Italie" + TAB + "Pise")
    TreeAdd(ARBRE_Ville, "Italie" + TAB + "Milan")
    TreeAdd(ARBRE_Ville, "Espagne" + TAB + "Barcelone")
    TreeAdd(ARBRE_Ville, "Espagne" + TAB + "Madrid")
    TreeAdd(ARBRE_Ville, "Espagne" + TAB + "Valence")
  • Fill from a data file:
    // Lecture familles
    FOR EACH Famille
    	// Ajout de la famille dans l'arbre (niveau 1: racine) 
    	TreeAdd(ARBRE_Produits, Famille.libellé)
    
    	// Lecture des sous-familles
    	FOR EACH SousFam where IDFamille = Famille.IdFamille
    		// Ajout de la sous-famille (niveau 2: branche 1) 
    		TreeAdd(ARBRE_Produits, Famille.libellé + TAB + SousFam.libellé)
    
    		// Lecture des produits
    		FOR EACH PRODUIT where IdSousFam = SousFam.IdSousFam
    			// Ajout du produit: (feuille)
    			TreeAdd(ARBRE_Produits, 
    				Famille.libellé + TAB + SousFam.libellé + TAB + PRODUIT.LibProd)
    		END
    	END
    END
TreeInsert function: Insert 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:
ArbreInsère(<Nom Arbre>, <Feuille frère>, <Nouvelle feuille>,
<Image enroulée>, <Image déroulée>, <Identifiant>)
For more details, see the help page on the TreeInsert function.

Code example

TreeAdd(ARBRE_Ville, "France")
TreeAdd(ARBRE_Ville, "Italie")
TreeAdd(ARBRE_Ville, "France" + TAB + "Paris")
TreeAdd(ARBRE_Ville, "France" + TAB + "Marseille")
TreeAdd(ARBRE_Ville, "France" + TAB + "Lyon")

// Insère les villes de Montpellier et Bordeaux au même niveau que Lyon
TreeInsert(ARBRE_Ville, "France" + TAB + "Lyon", "Montpellier")
TreeInsert(ARBRE_Ville, "France" + TAB + "Lyon", "Bordeaux")
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/21/2024

Send a report | Local help