finding the parent

How can i find the parent of a child node in a treeview in delphi 2?
XperlAsked:
Who is Participating?
 
DidierDConnect With a Mentor Commented:
Hi,

Put a TTreeView, a TButton and a TEdit on a form and add some items to the treeview. Add the code below to the button. Run it, select a node and press the button. The text of the parent node will appear in the editbox.

procedure TForm1.Button1Click(Sender: TObject);
var
  SelNode: TTreeNode;
  ParentNode: TTreeNode;
begin
  SelNode := TreeView1.Selected;
  ParentNode := SelNode.Parent;
  edit1.Text := ParentNode.Text;
end;

Didier
0
 
DidierDCommented:
I'm using Delphi 5, but i think it is the same for Delphi 2

Didier
0
 
XperlAuthor Commented:
Thanks DidierD.  That code did the trick, ta.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.