DEFINE TREE
Creates
a Tree Control
Standard Syntax (xBase
Style):
DEFINE TREE <ControlName>
[ OF | PARENT <ParentWindowName> ]
AT <nRow> ,<nCol>
WIDTH <nWidth>
HEIGHT <nHeight>
[ VALUE <nValue> ]
[ FONT <cFontname> SIZE <nFonSize>
]
[ TOOLTIP <cToolTipText> ]
[ ON GOTFOCUS <OnGotFocusProcedur> | <bBlock> ]
[ ON CHANGE <OnChangeProcedure> | <bBlock> ]
[ ON LOSTFOCUS <OnLostFocusProcedure> | <bBlock> ]
[ ON DBLCLICK <OnDblClickProcedure> | <bBlock> ]
[ BREAK ]
[ NODEIMAGES <aImgNode> [ ITEMIMAGES <aImgItem> ]
[ <noBut: NOROOTBUTTON> ]
[ ITEMIDS ]
[ HELPID <nHelpId> ]
...
...
[ NODE <cNodeCaption> ]
[ IMAGES <aImage> ]
[ ID <nItemID> ]
...
[ TREEITEM <cTreeItemCaption>
[ IMAGES <aImage> ]
[ ID <nItemID> ] ]
...
[ END NODE ]
...
...
END TREE
Alternate Syntax:
DEFINE TREE <ControlName>
[ PARENT <ParentWindowName> ]
ROW <nRow>
COL <nCol>
WIDTH <nWidth>
HEIGHT <nHeight>
[ VALUE <nValue> ]
[ FONTNAME <cFontname> ]
[ FONTSIZE <nFonSize> ]
[ TOOLTIP <cToolTipText> ]
[ ONGOTFOCUS <OnGotFocusProcedure> | <bBlock> ]
[ ONCHANGE <OnChangeProcedure> | <bBlock> ]
[ ONLOSTFOCUS <OnLostFocusProcedure> | <bBlock> ]
[ ONDBLCLICK <OnDblClickProcedure> | <bBlock> ]
[ BREAK <lValue> ]
[ NODEIMAGES <aImgNode> ]
[ ITEMIMAGES <aImgItem> ]
[ ROOTBUTTON <lValue> ]
[ ITEMIDS <lValue> ]
[ HELPID <nHelpId> ]
...
...
[ NODE <cNodeCaption> ]
[ IMAGES <aImage> ]
[ ID <nItemID> ]
...
[ TREEITEM <cTreeItemCaption>
[ IMAGES <aImage> ]
[ ID <nItemID> ] ]
...
[ END NODE ]
...
...
END TREE
Properties:
- Value
- Enabled
- Visible
- Row
- Col
- Width
- Height
- Item ( nItemIndex | nItemID )
- FontName
- FontSize
- FontBold
- ToolTip
- Name (R)
- Break (D)
- NodeImages (D)
- ItemImages (D)
- HelpId (D)
- Parent (D)
- RootButton (D)
D: Available at control definition only
R: Read-Only
Events:
- OnChange
Methods:
- Show
- Hide
- AddItem ( cItemText
, nParentItemIndex | nParentItemID
)
- DeleteItem ( nItemIndex | nItemID )
- Expand ( nItemIndex | nItemID )
- Collapse ( nItemIndex | nItemID )
- SetFocus
- Release
When ITEMIDS
clause is specified, you can assign a numeric ID (ID clause) to tree items and
nodes. That way, all tree properties and methods will work using these ID's
instead item position.
# TREE Control improvement
Note: nValue = nItemIndex
| nItemID
- New
Get Properties:
<ParentWindowName>.<TreeControlName>.AllValue --> anAllItemsValues | NIL
<ParentWindowName>.<TreeControlName>.RootValue --> nValue | NIL
<ParentWindowName>.<TreeControlName>.FirstItemValue --> nValue | NIL
<ParentWindowName>.<TreeControlName>.ParentValue ( nValue
) --> nValue
| NIL
<ParentWindowName>.<TreeControlName>.ChildValue ( nValue
) --> anChildItemsValues
| NIL
<ParentWindowName>.<TreeControlName>.SiblingValue ( nValue
) --> anSiblingItemsValues
| NIL
<ParentWindowName>.<TreeControlName>.ItemText ( anItemsValues
) --> acItemsText
| NIL
<ParentWindowName>.<TreeControlName>.IsTrueNode ( nValue
) --> lBoolean
<ParentWindowName>.<TreeControlName>.NodeFlag ( nValue
) --> lBoolean
<ParentWindowName>.<TreeControlName>.ImageCount --> nImageCount
<ParentWindowName>.<TreeControlName>.ImageIndex ( nValue
) --> { iUnSelectItem
, iSelectItem }
- New
Set Properties:
<ParentWindowName>.<TreeControlName>.NodeFlag ( nValue
) := lBoolean
<ParentWindowName>.<TreeControlName>.ImageIndex ( nValue
) := { iUnSelectItem
, iSelectItem }
<ParentWindowName>.<TreeControlName>.AddImage := cImageName
<ParentWindowName>.<TreeControlName>.TextColor := anRGBcolor
<ParentWindowName>.<TreeControlName>.BackColor := anRGBcolor
<ParentWindowName>.<TreeControlName>.LineColor := anRGBcolor
- New
Methods:
<ParentWindowName>.<TreeControlName>.Expand ( nValue , lRecursive )
<ParentWindowName>.<TreeControlName>.Collapse
( nValue , lRecursive
)
<ParentWindowName>.<TreeControlName>.DisableUpdate
<ParentWindowName>.<TreeControlName>.EnableUpdate
<ParentWindowName>.<TreeControlName>.SetDefaultAllNodeFlag
<ParentWindowName>.<TreeControlName>.SetDefaultNodeFlag ( nValue
)
<ParentWindowName>.<TreeControlName>.Sort
( nValue , lRecursive,
lCaseSensitive, lAscendingOrder,
nNodePosition
)
TREESORT ControlName OF ParentName
[ ITEM nValue ]
[ RECURSIVE lRecursive ]
[ CASESENSITIVE lCaseSensitive ]
[ ASCENDINGORDER lAscendingOrder ]
[ NODEPOSITION nNodePosition ]
nNodePosition
= TREESORTNODE_FIRST | TREESORTNODE_LAST | TREESORTNODE_MIX
Note:
<ParentWindowName>.<TreeControlName>.IsTrueNode ( nValue ) --> Only returns .T. if the item contain
sub-items (child items).
<ParentWindowName>.<TreeControlName>.NodeFlag ( nValue ) := lBoolean
--> This flag allows you to force an Item to be Node (.T.) or not (.F.).
This flag only affect the Nodes positions when run the Sort method.
For more information about of the new features see demo SortTreeDir in SAMPLES folder.