(Gast)
n/a Beiträge
|
Re: TreeView Ordnerstruktur - Items an richtige Position set
14. Aug 2007, 10:26
Ich hab das mal in ähnlicher Form so realisiert:
Delphi-Quellcode:
procedure Tfrmxyz.Button8Click(Sender: TObject);
procedure GetDirs(const ADirectory: string; var Tree: TTreeView; Start: TTreeNode);
//-------Anfang inbound function-------------
function SlashSep(const Path, S: string): string;
begin
if AnsiLastChar(Path)^ <> '\' then
Result := Path + '\' + S else
Result := Path + S;
end;
//------Ende inbound function
//-------Anfang inbound Proc------------------
var SearchRec: TSearchRec;
NewNode: TTreeNode;
begin
if FindFirst(SlashSep(ADirectory, '*.*'), faDirectory, SearchRec) = 0 then begin
try
repeat
if ((SearchRec.Attr and faDirectory) <> 0) then begin
if ((SearchRec.Name <> '.') and (SearchRec.Name <> '..')) then begin
NewNode:=Tree.Items.AddChild(Start, SearchRec.Name);
GetDirs(SlashSep(ADirectory, SearchRec.Name), Tree, NewNode);
end;
end;
until FindNext(SearchRec) <> 0;
finally
SysUtils.FindClose(SearchRec);
end;
end;
end;
//--------Ende inbound Proc------------------
var tn: TTreeNode;
begin
TreeView1.Items.BeginUpdate;
TreeView1.Items.Clear;
tn:= TreeView1.Items.Add(nil,'Pladde D'); //RootKnoten
GetDirs('D:\*.*', TreeView1, tn);
TreeView1.Items.EndUpdate;
end;
|
|
Zitat
|