PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Collapsing/Expanding a treeview by programming
  • Example
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
Collapsing/Expanding a treeview by programming
  • To collapse a treeview by programming, all you have to do is use TreeCollapse.
  • To expand a treeview by programming, all you have to do is use TreeListItem combined with a specific local procedure.
Versions 19 and later
WINDEV Note: To optimize the filling of a TreeView control, you have the ability to use ..AddChildDelayed on the rows of the TreeView control. This property is used to define the procedure that will be run to fill the level to expand. The search for children and the fill of children are performed only when the user wants to see them.
New in version 19
WINDEV Note: To optimize the filling of a TreeView control, you have the ability to use ..AddChildDelayed on the rows of the TreeView control. This property is used to define the procedure that will be run to fill the level to expand. The search for children and the fill of children are performed only when the user wants to see them.
WINDEV Note: To optimize the filling of a TreeView control, you have the ability to use ..AddChildDelayed on the rows of the TreeView control. This property is used to define the procedure that will be run to fill the level to expand. The search for children and the fill of children are performed only when the user wants to see them.
Example
The following codes are used to:
  • initialize a TreeView control.
  • expand part of the TreeView control.
  • collapse the TreeView control.
  1. Initialize the TreeView control by programming:
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert", "CAKE-.BMP", "CAKE-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Ice cream")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Ice cream" + ...
    TAB + "Vanilla", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Ice cream" + ...
    TAB + "Strawberry", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Ice cream" + ...
    TAB + "Chocolate", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Cup")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Cup" + ...
    TAB + "Banana Split", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Cup" + ...
    TAB + "Cherry Garcia", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Cup" + ...
    TAB + "Colonel", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Apple pie")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Apple pie" + ...
    TAB + "with whipped cream", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Apple pie" + ...
    TAB + "with apple brandy", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Crème brûlée", "NEXT5-.BMP")
    TreeAdd(TREE_RecipeTV, "Recipe" + TAB + "Dessert" + TAB + "Meringue with cream", "NEXT5-.BMP")
  2. Expand all the elements: The "ExpandAll" procedure is called for each "child" element found. This procedure expands all the collapsed "child" nodes of the "Dessert" node.
    // Lists the "children" of "Desserts" node in "TREE_RecipeTV" treeview
    // The "ExpandAll" procedure is called
    // for each "child" of the "Desserts" node found
    Res = TreeListItem(TREE_RecipeTV, "Recipe" + TAB + "Dessert", "ExpandAll")
    // Local procedure named "ExpandAll"
    // This procedure expands all the collapsed "child" nodes of the "Desserts" node
    PROCEDURE ExpandAll(TREE_RecipeTV, ChildPath, ChildFound, Level, Pointer)
    // Is the element found a leaf?
    IF TreeTypeItem(TREE_RecipeTV, ChildPath + ChildFound) = tvLeaf THEN
            RETURN  // Back to TreeListItem
    ELSE
            // Is the element found collapsed?
            IF TreeStatus(TREE_RecipeTV, ChildPath + ChildFound) = tvCollapse THEN
                    TreeExpand(TREE_RecipeTV, ChildPath + ChildFound)
            END
    END
  3. Collapse the "Dessert" node.
    // Collapses the "Desserts" node in "TREE_RecipeTV"
    Res = TreeCollapse(TREE_RecipeTV, "Recipe" + TAB + "Dessert")
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment