procedure TForm1.CreateTree(ID: Integer; Node: TTreeNode);
//¶¯Ì¬´´½¨Ê÷
var
iPartID:Integer;
TreeNode: TTreeNode;
myQuery:TQuery;
const
SQLStr1='select * from systemtree where pid=%d';
begin
myQuery:=TQuery.Create(Self);
try
with myQuery do
begin
DatabaseName:='aaa';
SQL.Add(Format(SQLStr1,[Id]));
Open;
while not Eof do
begin
iPartID:=FieldByName('id').AsInteger;
TreeNode:=tvTree.Items.AddChild(Node,FieldByName('id').Asstring);
TreeNode.StateIndex:=iPartID;
CreateTree(iPartID,TreeNode);
Next;
end;
Close;
end;
finally
myQuery.Free;
end;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
tvTree.Items.Clear;
CreateTree(1,nil);
end;