troubleshooting Question

Get full path of a TreeNode

Avatar of menorcanet
menorcanetFlag for Spain asked on
2 Comments1 Solution1133 ViewsLast Modified:
How can I get the full path (text) from the root up to a specific TreeNode item in a TreeView?

Let's say we have this:

By giving our function the node temp, it would return Windows\CSC\v.2.0.6\temp

I've looked at browsing backwards while Level > 0 but there's no method to retrieve the PARENT node, only GetPrev, GetPrevChild, getPrevSibling, GetPrevVisible .. none of which give us the parent node. If we had that I could do something like

procedure FoldersTreeDragDrop(Sender, Source: TObject; X, Y: Integer);
var AnItem: TTreeNode;
    s: string;
   AnItem := FoldersTree.GetNodeAt(X, Y);
   s := AnItem.Text+'\';
   while AnItem.Level > 0 do
     AnItem := AnItem.GetPrev.. Parent?;
     s := AnItem.Text+'\'+s;

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros