首页  编辑  

Return the String Path in a TTreeView?

Tags: /超级猛料/VCL/TreeView/   Date Created:

Return the String Path in a TTreeView?

{*---------------------------------------------

Parent Text

---------------------------------------------*}

function SrNodeTree(pTreeNode: TTreeNode; var sRuta: string): string;

begin

 sRuta := pTreeNode.Text + ' > ' + sRuta;

 if pTreeNode.Level = 0 then Result := sRuta

 else  

   Result := SrNodeTree(pTreeNode.Parent, sRuta);

end;

{*---------------------------------------------

 Click an Item

---------------------------------------------*}

procedure TForm1.TreeView1Click(Sender: TObject);

var

 sPath: string;

begin

 label1.Caption := SrNodeTree(TreeView1.Selected, sPath);

end;

img_1405.bmp (172.3KB)