Page 1 of 1
How to EXPAND TREE with single command
Posted: Mon Nov 21, 2022 7:42 pm
by serge_girard
Hello,
I have a TREE and after filling it up I want to show it in full. Now I have to click on every 'plus' sign in order to expand. Some branches are opened at start but most of them I have to click on.
Thanks, Serge
Re: How to EXPAND TREE with single command
Posted: Mon Nov 21, 2022 9:24 pm
by andyglezl
Maybe...
Code: Select all
IF Form_1.Tree_1.IsExpand( Form_1.Tree_1.Value )
Form_1.Tree_1.Collapse( Form_1.Tree_1.Value )
ELSE
Form_1.Tree_1.Expand( Form_1.Tree_1.Value )
ENDIF
Re: How to EXPAND TREE with single command
Posted: Tue Nov 22, 2022 6:35 am
by serge_girard
Andres,
And in a loop?
Serge
Re: How to EXPAND TREE with single command
Posted: Tue Nov 22, 2022 8:27 am
by edk
Yeap, in a loop:
Code: Select all
Function ExpandAll ()
Local nValue
FOR EACH nValue IN Form_1.Tree_1.AllValue
IF Form_1.Tree_1.IsTrueNode ( nValue ) .AND. Empty ( Form_1.Tree_1.ParentValue ( nValue ) )
Form_1.Tree_1.Expand ( nValue /* main nodes */ , .T. /* recursive */ )
ENDIF
NEXT
RETURN
**********************************************************
Function CollapseAll ()
Local nValue
FOR EACH nValue IN Form_1.Tree_1.AllValue
IF Form_1.Tree_1.IsTrueNode ( nValue ) .AND. Empty ( Form_1.Tree_1.ParentValue ( nValue ) )
Form_1.Tree_1.Collapse ( nValue /* main nodes */ , .T. /* recursive */ )
ENDIF
NEXT
RETURN
Re: How to EXPAND TREE with single command
Posted: Tue Nov 22, 2022 9:00 am
by gfilatov
Hi Serge,
Please take a look the updated sample below which was posted by our late friend Bicahi Esgici in 2008:
Code: Select all
/*
MINIGUI - Harbour Win32 GUI library Demo/Sample
Copyright 2002-08 Roberto Lopez <harbourminigui@gmail.com>
TreeMenu is Freeware HMG TREE sample.
Author : Bicahi Esgici
Not really an alternative "menu", simply denote to evaluate
ON DBLCLICK event in TREE.
Since NODE and TREEITEM statements does not have any event
definition, event management in TREE require a little
different way.
All bug reports and suggestions are welcome.
Developed under Harbour Compiler and
MINIGUI - Harbour Win32 GUI library (HMG).
Thanks to "Le Roy" Roberto Lopez.
*/
#include "minigui.ch"
PROCEDURE Main()
DEFINE WINDOW frmTreeMenu ;
AT 0,0 ;
WIDTH 640 ;
HEIGHT 480 ;
TITLE 'Tree Menu Sample' ;
MAIN ;
ON INIT ExpandAll()
ON KEY ESCAPE ACTION frmTreeMenu.Release
DEFINE TREE treMenu AT 0,0 WIDTH 100 HEIGHT 160 ;
ON DBLCLICK { || RunAction( this.Value ) }
NODE 'New' // 1
TREEITEM 'Table' // 2
TREEITEM 'Text' // 3
TREEITEM 'Project' // 4
END NODE
NODE 'Open' // 5
TREEITEM 'Table' // 6
TREEITEM 'Text' // 7
TREEITEM 'Project' // 8
END NODE
END TREE
END WINDOW
CENTER WINDOW frmTreeMenu
ACTIVATE WINDOW frmTreeMenu
RETURN // Main()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE ExpandAll()
LOCAL i
FOR i := 1 TO frmTreeMenu.treMenu.ItemCount
IF TreeItemIsTrueNode( 'treMenu', 'frmTreeMenu', i )
frmTreeMenu.treMenu.Expand( i, .T. )
ENDIF
NEXT
RETURN // ExpandAll()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE RunAction( ;
nTreeItemNo )
SWITCH nTreeItemNo
CASE 2 // New Table
NewTable()
EXIT
CASE 3 // New Text
NewText()
EXIT
CASE 4 // New Project
NewProject()
EXIT
CASE 6 // Open Table
OpenTable()
EXIT
CASE 7 // Open Text
OpenText()
EXIT
CASE 8 // Open Project
OpenProject()
ENDSWITCH
RETURN // RunAction()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE NewTable()
MsgBox( "New Table procedure will run." )
RETURN // NewTable()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE NewText()
MsgBox( "New Text procedure will run." )
RETURN // NewText()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE NewProject()
MsgBox( "New Project procedure will run." )
RETURN // NewProject()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE OpenTable()
MsgBox( "Open Table procedure will run." )
RETURN // OpenTable()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE OpenText()
MsgBox( "Open Text procedure will run." )
RETURN // OpenText()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE OpenProject()
MsgBox( "Open Project procedure will run." )
RETURN // OpenProject()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
Re: How to EXPAND TREE with single command
Posted: Tue Nov 22, 2022 1:07 pm
by serge_girard
Thanks Grigory & Edward (+ the laste Esgici RIP)
I wil give it try!
Serge
Re: How to EXPAND TREE with single command
Posted: Wed Nov 23, 2022 3:02 pm
by andyglezl
serge_girard wrote: ↑Tue Nov 22, 2022 6:35 am
Andres,
And in a loop?
Serge
Hi Serge
<ParentWindowName>.<TreeControlName>.Expand ( nValue , lRecursive )
<ParentWindowName>.<TreeControlName>.Collapse ( nValue , lRecursive )