lprocedure TForm1.ReadTree(tnode:TTreeNode;Fvalue: String);
lVar
l i: integer;
l Flist:TStringList;
l Flist1:TStringList;
l str:string;
lbegin
l qryTree.close;
l qryTree.sql.clear;
l qryTree.sql.add('select Parentid,id,context from tbtree');
l qryTree.sql.add('where isnull(Parentid,'''')=');
l qryTree.sql.add(''''+Fvalue+'''');
l qryTree.Open;
l qryTree.First;
l Flist:=TStringList.Create;
l Flist1:=TStringList.Create;
l while not qryTree.eof do
l begin
l Flist.Add(trim(qryTree.fieldbyname('context').asstring));
l Flist1.Add(qryTree.fieldbyname('id').asstring);
l qryTree.next;
l end;
l for i:= 0 to flist.Count-1 do
l begin
l s:=flist1.Strings[i];
l str:=flist.Strings[i];
l snode:=Treeview1.items.addchild(tnode,str);
l ReadTree(snode,s);
l end;
l flist.free;
l flist1.free;
lend;