Board index » delphi » treeview. full path??

treeview. full path??

function GetPathFromNodes (SelNode : TTreeNode) : String;
var
  prnNode : TTreeNode;
begin
  Result := SelNode.Text + '\';
  prnNode := SelNode.Parent;
  while prnNode <> nil do begin
    Result := prnNode.Text + '\' + Result;
    prnNode := prnNode.Parent;
  end;
end;

This will give you the appearance of '\Node1\Node2\Node3\Node4\Node5' etc.
Not so flexible, but it should demonstrate basically what you wish to do. :)

Good Luck,

Michael

Quote
William Tseng wrote in message <34E48E18.1FF0B...@writeme.com>...
>I write to ask if any one knows :
>Suppose i use Ttreeview as a file list,
>how can i have a full path name whenever
>user expend the folder(click on the "plus")?
>say.
>          abc--
>                defg--
>                     hij
>how do i get "abc\defg\hij\" when hij was selected?
>Thanks for your time.

>william.ts...@writeme.com

 

Re:treeview. full path??


I write to ask if any one knows :
Suppose i use Ttreeview as a file list,
how can i have a full path name whenever
user expend the folder(click on the "plus")?
say.
          abc--
                defg--
                     hij
how do i get "abc\defg\hij\" when hij was selected?
Thanks for your time.

william.ts...@writeme.com

Re:treeview. full path??


Hi William
try this.
/*---------------------------------------------------------------------*/
AnsiString __fastcall AddSlash(const AnsiString S1, const AnsiString S2)
{
   AnsiString retStr;
   if (*AnsiLastChar(S1) != '\\')
      retStr = S1 + '\\' + S2;
   else
      retStr = S1 + S2;
   return retStr;

Quote
}

/*---------------------------------------------------------------------*/
AnsiString __fastcall GetNodePath(TTreeNode* Node)
{
   AnsiString retStr;
   if (Node)
   {
      TTreeNode* p = Node->Parent;
      retStr = Node->Text;
      while (p)
      {
         retStr = AddSlash(p->Text, retStr);
         p = p->Parent;
      }
   }
   return retStr;
Quote
}

/*---------------------------------------------------------------------*/
sorry but this code is C code not pascal i work with C++ Builder
Bye Fred

William Tseng a crit dans le message <34E48E18.1FF0B...@writeme.com>...

Quote
>I write to ask if any one knows :
>Suppose i use Ttreeview as a file list,
>how can i have a full path name whenever
>user expend the folder(click on the "plus")?
>say.
>          abc--
>                defg--
>                     hij
>how do i get "abc\defg\hij\" when hij was selected?
>Thanks for your time.

>william.ts...@writeme.com

Other Threads