AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / Desarrollar una aplicación o un sitio web / Controles, ventanas y páginas / Controles: tipos disponibles / Control TreeView
  • Contraer/Expandir un TreeView mediante programación
  • Ejemplo
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Contraer/Expandir un TreeView mediante programación
  • Para colapsar un control TreeView mediante programación, use TreeCollapse.
  • Para expandir un TreeView mediante programación, utiliza TreeListItem con un procedimiento local específico.
Ejemplo
Los siguientes códigos se utilizan para:
  • inicializar un control TreeView.
  • 0.
  • 0.
  1. Inicializa el control TreeView programáticamente:
    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")
    TreeAdd(TREE_TVRecipe, "Recipe" + TAB + "Dessert" + TAB + "Cup")
    TreeAdd(TREE_TVRecipe, "Recipe" + TAB + "Dessert" + TAB + "Cup" + ...
    		TAB + "Banana Split", "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 brûlée", "NEXT5-.BMP")
    TreeAdd(TREE_TVRecipe, "Recipe" + TAB + "Dessert" + TAB + "Meringue with cream", "NEXT5-.BMP")
  2. Expande todos los elementos. Se llama al procedimiento "ExpandAll" para cada elemento "child" encontrado. Este procedimiento expande todos los nodos "hijo" colapsados del nodo "Postre".
    // Lists the "children" of "Desserts" node in "TREE_TVRecipe" treeview
    // The "ExpandAll" procedure is called
    // for each "child" of "Desserts" node found
    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  // Back to TreeListItem
    ELSE
    	// Is the element found collapsed?
    	IF TreeStatus(TREE_TVRecipe, ChildPath + ChildFound) = tvCollapse THEN
    		TreeExpand(TREE_TVRecipe, ChildPath + ChildFound)
    	END
    END
  3. Colapsar el nodo "Dessert".
    // Collapses the "Desserts" node in the "TREE_TVRecipe" control
    Res = TreeCollapse(TREE_TVRecipe, "Recipe" + TAB + "Dessert")
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 12/03/2025

Señalar un error o enviar una sugerencia | Ayuda local