创建商品树的原代码:
procedure findparent(anode : Ttreenode); //为每个节点找父亲
var
i : integer;
parent : integer;
tempnode : Ttreenode;
begin
parent := Pnode(anode.Data)^.pid;
for i := 0 to list1.count-1 do
begin
tempnode := Ttreenode(list1[i]);
if Pnode(tempnode.Data)^.id = parent then
begin
anode.MoveTo(tempnode,naAddchild); //将子节点添加到父亲节点下
break;
end;
end;
end;
procedure TForm5.FormActivate(Sender: TObject);
var
nodeinfo : Pnode;
n : integer;
node : Ttreenode;
begin
list1 := Tlist.Create ;
list1.Clear;
data1.quy_spbxx.Open;
with data1.quy_spbxx do //遍历树的节点
begin
first;
while not eof do
begin
node := tv.items.add(nil,trim(fieldvalues['商品部名称']));
new(nodeinfo);
nodeinfo^.id := fieldvalues['商品部编码'];
nodeinfo^.pid := fieldvalues['pid'];
node.data := nodeinfo;
list1.Add(node) ;
Next;
end;
for n:= 0 to list1.count-1 do
<< 上一页 [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] ... 下一页 >>