unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure AddNodeList(NodeFirst:TTreeNode);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
NodeTest:TTreeNode;
begin
NodeTest:= TreeView1.Selected.getFirstChild; // 可以添加适当的节点过滤条件--genispan
ListBox1.Items.Add(NodeTest.Text);
AddNodeList(NodeTest);
end;
procedure TForm1.AddNodeList(NodeFirst:TTreeNode);
begin
if NodeFirst.getNextSibling<>nil then
begin
ListBox1.Items.Add(NodeFirst.getNextSibling.Text);
AddNodeList(NodeFirst.getNextSibling);
end;
end;
end.