Guten Morgen.
Bei mir funktioniert es so:
Delphi-Quellcode:
procedure GetLeaves(tn: TTreeNode; sLeaves, sParents: TStrings);
var
tnChild: TTreeNode;
begin
if Assigned(sParents) then
sParents.Add(tn.Text);
if tn.HasChildren then
begin
tnChild := tn.getFirstChild;
while Assigned(tnChild) do
begin
GetLeaves(tnChild, sLeaves, sParents);
tnChild := tnChild.getNextSibling;
end;
end else
if Assigned(sParents)
then sLeaves.Add(sParents.DelimitedText)
else sLeaves.Add(tn.Text);
sParents.Delete(Pred(sParents.Count));
end;
procedure TDemoForm.ButtonClick(Sender: TObject);
var
i: Integer;
tn: TTreeNode;
sParents: TStrings;
begin
Memo.Clear;
Memo.Lines.BeginUpdate;
tn := TreeView.Items.GetFirstNode;
sParents := TStringList.Create;
sParents.Delimiter := '\';
while Assigned(tn) do
begin
GetLeaves(tn, Memo.Lines, sParents);
tn := tn.getNextSibling;
end;
sParents.Free;
Memo.Lines.EndUpdate;
end;
Frohe Ostern
marabu