ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / TreeView functions
  • List of child elements
TreeListItem (Example)
List of child elements
The following code is used to:
  1. Initialize the TreeView control,
  2. List the "child" elements of the "Desserts" node in the "TREE_TVRecipe" treeview. The "ExpandAll" procedure is called for each "child" element found. This procedure expands all the collapsed "child" nodes of the "Desserts" node.
  3. Collapse all the treeview elements.
// Initialize the treeView
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert","CAKE-.BMP","CAKE-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Ice cream")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Ice cream" + TAB + "Vanilla", ...
"NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Ice cream" + TAB + "Strawberry", ...
"NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Ice cream" + TAB + "Chocolate", ...
"NEXT5-.BMP")
TreeExpand(TREE_TVRecipe,"Recipe" + TAB + "Dessert"+ TAB + "Ice cream")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Cup")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Cup" + TAB + ...
"Peach Melba", "NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Cup" + TAB + ...
"Cherry Garcia", "NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Cup" + TAB + "Colonel", ...
"NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Apple pie")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Apple pie" + TAB + ...
"with whipped cream", "NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Apple pie" + TAB + ...
"with apple brandy", "NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Crème brulée","NEXT5-.BMP")
TreeAdd(TREE_TVRecipe,"Recipe" + TAB + "Dessert" + TAB + "Meringue with ice cream","NEXT5-.BMP")
TreeExpand(TREE_TVRecipe,"Recipe" + TAB + "Dessert")
 
// Lists the "children" of "Desserts" node in "TREE_TVRecipe" treeview
// The "ExpandAll" procedure is called
// for each "child" element found in the "Desserts" node
Res is int
Res = TreeListItem(TREE_TVRecipe, "Recipe" + TAB + "Dessert", "ExpandAll")
//--------------------------------------------------------------------------------------------
// Local procedure named "ExpandAll"
// This procedure expands all the collapsed "child" nodes of the "Desserts" node
 
PROCEDURE ExpandAll(TREE_TVRecipe, ChildPath, ChildFound, Level, Pointer)
// Is the element found a leaf?
IF TreeTypeItem(TREE_TVRecipe, ChildPath + ChildFound) = tvLeaf THEN
RETURN // Go back to the TreeListItem function
ELSE
// Is the element found collapsed?
IF TreeStatus(TREE_TVRecipe, ChildPath + ChildFound) = tvCollapse THEN
TreeExpand(TREE_TVRecipe, ChildPath + ChildFound)
END
END
// Collapses the treeview
TreeCollapse(TREE_TVRecipe, "Recipe")
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help