var 
   Tnode:Ttreenode;
begin
with treeview1 do
begin
  if not Table1.actived then
     table1.actived:=true;
  if not Table2.Actived then
     table2.actived:=true;
   Table2.filtered:=True;
  with table1 do
  begin
     first;
     while not eof do 
     begin
        Tnode:=items.add(fieldbyname('zonename').asstring);
        table2.filter:='zoneid='+fieldbyname('zoneid').asstring;
        table2.first;
        while not Table2.eof do
        begin
          items.add(Tnode,Table2.fieldbyname('phoneno').asstring);
          Table2.next;
        end;
     next;
     end;
  end;end;
其中Table1指向表zone
Table2指向表phone;

解决方案 »

  1.   

    哦!第十六行应改为:Tnode:=items.add(nil,fieldbyname('zonename').asstring);
    时间仓促,没在机子上调试,如果有错,请贴出来!
            
      

  2.   

    TO: wanwangzhiwang
    速度也太慢了
      

  3.   

    stella53(慕蓉云风):
    你的方法当然可行!可是如果实现起来要写的代码肯定很长!提问题的这位仁兄估计接触delphi的时间不长,你光提出方案他不一定实现的了,干脆你帮忙帮到底,直接写出完整的代码算了,让兄弟我也学点东西啊!