Button-Click event:
DO copytree WITH this.parent.treeview1, this.parent.treeview2
//This code calls a program file(copytree.prg) and passes two treeviews as a parameter
copytree.prg:
PARAMETERS objTVSrc, objTVDest
objTVDest.Nodes.Clear
//Deletes all the nodes of the treeview1 before coping
For Each lonode In objTVSrc.Nodes
WITH lonode
If ISNULL(lonode.Parent)
objtvdest.nodes.Add(,1, .Key, .Text)
//adds root nodes to the treeview2
ELSE
objtvdest.nodes.add(.parent.key,4,.key,.text)
// adds child nodes in treeview2
EndIf
ENDWITH
ENDFOR