whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

54 Visitors Online


 
...reconstruct full paths from a TreeView?
Autor: Robert Machula
[ Print tip ]  

Tip Rating (11):  
     


var
  
SL: TStringList;

// gibt den kompletten Pfad vom übergebenen Node zurück
// for one node...
function TForm1.GetDir(Node: TTreeNode): string;
var
  
s: string;
begin
  
s := Node.Text + '\';
  while Node.Parent <> nil do 
  begin
    
s    := Node.Parent.Text + '\' + s;
    Node := Node.Parent;
  end;
  Result := s;
end;


// geht alle Nodes durch
// for all nodes
procedure TForm1.Nodes_durchgehen(Tree: TTreeView; Node: TTreeNode);
var
  
i: Integer;
begin
  if 
Node.Count > 0 then 
  begin
    for 
i := 0 to Node.Count - 1 do 
    begin
      
Memo1.Lines.Add(GetDir(Node.Item[i]));
      if Node.Count > 0 then
        
Nodes_durchgehen(Tree, Node.Item[i]);
    end;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  
// Verzeichnisse auflisten
  // hierbei wird die Komponente als auch das Stammverzeichnis (z.B. 'C:\') übergeben
  
  // recreate List.
  // You should pass the root-node as argument
  
Nodes_durchgehen(TreeView1, TreeView1.Items[0]);
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners