>>>>I am trying to expand my treeview through command button. When the user press the command button, I want the node to expand from a selected point. I have the following code, my only problem is how do I identify the nodekey?
>>>>
>>>>*cmdbuttonexpand
>>>>.OleTreeView.nodes(.llnode).expanded = .t.
>>>>
>>>>In my OleTreeView.nodeclick I have the following code:
>>>>
>>>>*OleTreeView.nodeclick()
>>>>LPARAMETERS node
>>>>WITH thisform
>>>> .nodevalue = .OleTreeView.selectedItem.fullpath
>>>> .nodevalue = STRTRAN(.nodevalue,'\',' ')
>>>> .nodepath = .OleTreeView.selectedItem.fullpath
>>>> .llnode = node
>>>>ENDWITH
>>>>
>>>>I set the "node" to ".llnode" assuming that is the key, but it dosen't work. Where can I set the nodekey to a property so I can pass it in my expand command or I should say how do find the parameter llnode.
>>>>
>>>>Thanks
>>>>Nick Patel
>>>
>>>Nick,
>>>You already have a reference to node (SelectedItem). IOW :
>>>
>>>oNode = tv.SelectedItem
>>>oNode.Key = tv.SelectedItem.Key
>>>
>>>and so forth.
>>>
>>>
>>>* Tv custom expandall method
>>> Procedure ExpandAll
>>> Lparameters tnIndex
>>> Local lnIndex
>>> With this
>>> .Nodes(tnIndex).Expanded = .t.
>>> If .Nodes(tnIndex).Children > 0
>>> lnIndex = .Nodes(tnIndex).Child.Index
>>> .ExpandAll(lnIndex)
>>> Do while lnIndex # .Nodes(tnIndex).Child.LastSibling.Index
>>> lnIndex = .Nodes(lnIndex).Next.Index
>>> .ExpandAll(lnIndex)
>>> Enddo
>>> Endif
>>> Endwith
>>>Endproc
>>>
>>>* ExpandAll CommandButton.click
>>>With thisform.tv
>>> .ExpandAll(.SelectedItem.Index)
>>>Endwith
>>>
Would expand all subnodes of selected node.
>>>PS: There is a recursif call that doesn't check if recursion goes beyond allowable limit (max 128 do nesting).
>>>Cetin
>>
>>Thanks for replying Cetin, I am getting an OLE Error Code 0x8002006: Unknown Name when I call the expand routine in my command button as follows:
>>
>>
>>* Expand.click
>>With thisform.OleTreeView
>> .ExpandAll(.SelectedItem.Index)
>>Endwith
>>
>>
>>I did put your sample code in procedure. I don't have to really do anything in the OleTreeView.nodeclick since .SelectedItem.Index should be already picked up from Thisform.OleTreeView when I select a node, right? I have create always methods and have never used procedures, .ExpandAll should have worked, but apparently it doesn't seem to like it.
>>
>>Thanks
>>Nick Patel
>
>Nick,
>ExpandAll is a custom method for treeview subclass. If you want to make say a form method then it'd look like :
>
>
> Lparameters tnIndex
> Local lnIndex
> With this.OleTreeView
> .Nodes(tnIndex).Expanded = .t.
> If .Nodes(tnIndex).Children > 0
> lnIndex = .Nodes(tnIndex).Child.Index
> .ExpandAll(lnIndex)
> Do while lnIndex # .Nodes(tnIndex).Child.LastSibling.Index
> lnIndex = .Nodes(lnIndex).Next.Index
> .ExpandAll(lnIndex)
> Enddo
> Endif
>Endwith
>
Cetin
Ok I made the expandall a custom method and I am calling it as follows from my expand.click button:
With thisform
.expandall(.OleTreeView.SelectedItem.Index)
Endwith
However I am still getting an error
OLE Error Code 0x8002006: Unknown Name
when I get to my .expandall method on the line that says:
.ExpandAll(lnIndex)
Is this because of the recursive 128 max you was talking about. If I had 4 nodes and I select node 3 then expand, I still get the error and that is only 1 node of expansion.
node1===>node2===>node3====>node4
Anyway, thank you for your help, your techniques are exceptional.
Nick Patel