Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Print of treeview
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00889129
Message ID:
00889150
Views:
18
Riyaz,

One approach would be to use a recursive function to visit all the nodes in your treeview hierarchy using a method on your form that looks something like this:-
LPARAMETERS tcNodeKey, tnIndent

LOCAL lnNodeIndex

insert into tmpCursor values (ThisForm.oleTree.Nodes(tcNodeKey).text, tnIndent)

if ThisForm.oleTree.Nodes(tcNodeKey).Children > 0
   lnNodeIndex = ThisForm.oleTree.Nodes(tcNodeKey).Child.Index
   ThisForm.RecurseTreeNodes(ThisForm.oleTree.Nodes(lnNodeIndex).Key, tnIndent + 1)
	
   do while lnNodeIndex <> ThisForm.oleTree.Nodes(tcNodeKey).Child.LastSibling.Index
      lnNodeIndex = ThisForm.oleTree.Nodes(lnNodeIndex).Next.Index
      ThisForm.RecurseTreeNodes(ThisForm.oleTree.Nodes(lnNodeIndex).Key, tnIndent + 1)		
   enddo
endif
Then all you have to do is invoke something like this (from a button or other interface object).
create cursor tmpCursor (nodetext C(100), indent I)

ThisForm.RecurseTreeNodes(ThisForm.oleTree.Nodes(1).Key, 0)

if reccount("tmpCursor") > 0
   report form treedump preview
endif 
You will notice the "treedump" report which uses the tmpCursor values to display the treeviews contents. In its simplest form this report contains 1 field with an expression to simulate indentation.
replicate("  ", tmpCursor.indent) + tmpCursor.nodetext
HTH
Neil
Previous
Reply
Map
View

Click here to load this message in the networking platform