Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where is my logic this morning?
Message
De
22/10/2003 10:32:02
 
 
À
22/10/2003 09:34:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00841000
Message ID:
00841047
Vues:
27
This message has been marked as a message which has helped to the initial question of the thread.
Tracy,

You could try using recursion to populate the treeview. The code below processes the "root" nodes.
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)
endfor
I 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
endif
As 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.

HTH
Neil
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform