我的一个程序中的代码片段,希望对你有帮助。
procedure tform1.address;
var
mynode,mynode1,mynode2,mynode3,mynode4:ttreenode;
begin
mynode:=treeview1.Items.Add(nil,'我的家');
mynode1:=treeview1.Items.Addchild(mynode,'亲朋好友');
mynode1.ImageIndex:=4;
mynode3:=treeview1.items.addchild(mynode,'碟片管理');
mynode3.ImageIndex:=5;
table1.First;
while not table1.EOF do
begin
mynode2:=treeview1.items.addchild(mynode1,table1.fieldbyname('typename').asstring);
mynode2.ImageIndex:=3;
table1.Next;
end;
table3.First;
while not table3.EOF do
begin
mynode4:=treeview1.items.addchild(mynode3,table3.fieldbyname('typename').asstring);
mynode4.ImageIndex:=6;
table3.Next;
end;
end;