LOCAL lnNode LOCAL lnRootTotal LOCAL loRootNode LOCAL ARRAY laRootNodes[1] select * from al3parnt ; where cParent == "A0" ; into array laRootNodes lnRootTotal = _tally for lnNode = 1 to lnRootTotal loRootNode = ThisForm.oleTree.Nodes.Add(, 1, sys(2015), laRootNodes[lnNode, 2], 0, 0) loRootNode.Expanded = .T. loRootNode.Tag = laSource[lnNode, 3] ThisForm.LoadSubNodes(loRootNode) endforI could have found the root nodes in a number of ways, its not really important, what you should note is the call to the ThisForm::LoadSubNodes method listed below.
LPARAMETERS loParentNode LOCAL lnSubTotal LOCAL lnSubNode LOCAL loSubNode LOCAL ARRAY laSubNodes[1] select * from al3parnt ; where cParent == loParentNode.text ; and seq == loParentNode.tag ; into array laSubNodes lnSubTotal = _tally if _tally > 0 for lnSubNode = 1 to lnSubTotal loSubNode = ThisForm.oleTree.Nodes.Add(loParentNode, 4, sys(2015), laSubNodes[lnSubNode, 2], 0, 0) loSubNode.Expanded = .T. loSubNode.Tag = laSubNodes[lnSubNode, 3] ThisForm.LoadSubNodes(loSubNode) endfor endifAs you can see, this method calls itself recursively until it bottoms out. I have taken some shortcuts to keep the example simple, you probably wouldn't use _tally or sys(2015) and you would want to put a check in to test the ceiling on the recursion level which I believe is 128.