Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to optimize use of the treeview-control in VFP?
Message
From
29/01/1999 09:39:54
Juan Kh
Dataprop Technologies
Sungai Petani, Malaysia
 
 
To
29/01/1999 09:34:01
Juan Kh
Dataprop Technologies
Sungai Petani, Malaysia
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00181709
Message ID:
00181773
Views:
22
Sorry Frank, the line that add child node to the parent should look like this (I forgot to modify it to become general).

oNode = .nodes.add(parent,4,child,tmpTree.child,"icon","selectedicon")

juan

>Frank,
>
>You do not need to perform recursive task. Just get the child-parent info into your cursor (it should be a flat table, obtained by using SQL statement), and use the following code the add the node. TreeView will take care of the heirachy for you.
>
>WITH This.oleTree
>
> nLeft = .Left && Property to remember the original 'left'
> .left = -999 && To speed up the adding of nodes
> thisform.lockscreen = .t.
> oNode = .nodes.add(,,"_R0","My Top Node","TopIcon",)
> SELECT tmpTree && Must have child-parent info
> SCAN
>
> *-- Look for existance of 'parents'
>
> nNodeCount = .nodes.count
> FOR i = 1 to nNodeCount
> IF .nodes(i).key = parent
> llNodeExist = .t.
> exit
> ELSE
> llNodeExist = .f.
> ENDIF
> ENDFOR
>
> *-- Add the parent node if it does not exist
>
> IF !llNodeExist
> oNode = .nodes.add("_R0",4,parent,tmpTree.parent,"icon","selectedicon")
> ENDIF
>
> *-- This line will do the hierichy job for you
>
> oNode = .nodes.add(parent,4,accno,tmpAccountTree.child + space(1) + alltrim(tmpAccountTree.desp),"clsfolder","openfolder")
>
> ENDSCAN
>
> .left = nLeft
>ENDWITH
>
>
>Hope it helps,
>juan
>
>>I'm currently doing a project involving using two treeview
>>controls to make a structure.
>>The structure can consist of several thousands nodes.
>>- What's the best way to recursively add the nodes in the tree?
>> All the data for the nodes in the right three are gathered on
>> startup and loaded into a VFP cursor. I've found that
>> SCAN
>> ...
>> ENDSCAN
>> doesn't work very well with recursive functions.
>> The max number of levels in the tree will be about 5-6.
>> Is it better to make the addnodes-function non-recursive for
>> speed-improvements?
>>- What's the best way to get the a branch of the tree on the left
>> and add to a selected node in the tree to the right?
>> I've programmed one recursively, but it performs poorly when
>> the number of nodes in the branch approaches >1000 nodes.
>>
>>Any suggestions, algorithms, URLs or help on this matter would be highly appreciated.
Previous
Reply
Map
View

Click here to load this message in the networking platform