建一颗多层的树结构,如何建立?最好能告诉我代码!!谢了!!!

解决方案 »

  1.   

    不懂,TTreeView本来就是多层的树嘛,
    可能是俺愚昧吧:)
      

  2.   

    我也非常非常需要呀?
    如果可能的话给我发到邮箱去:[email protected]
      

  3.   

    我的email是:[email protected],发给我一份,谢谢了!
      

  4.   

    我的email是:[email protected], 给我一份谢谢
      

  5.   

    my email:[email protected],very thanks!!!!
      

  6.   

    正在紧急寻找中...........
    [email protected]
      

  7.   

    能给我一个吗,
    [email protected]谢谢了
      

  8.   

    3、用递归:
    首先,在单元接口部分声明一记录类型及其指针,用来保存你的树节点需传递的信息。
    type
      pchar=^str;
      str=record
        tcaption:string;
        num:integer;
      end;
    写一生成树的函数,注意递归:
    function TForm1.ShowTree(TNode: TTreeNode; s: string): boolean;
    var
      QR:TADOQuery;
      TmpNode:TTreeNode;
      p:pchar;
    begin
      QR:=TADOQuery.Create(self);
      if TNode=nil then //判断是否顶层接点 ;
      begin
        new(p);
        p^.tcaption:=s;
        p^.num:=1;
        TNode:=Treeview1.Items.AddChildObject(TNode,p^.tcaption,p);
      end;
      with QR,treeview1 do
      begin
        close;
        connection:=ADOCONNECTION1;
        SQL.Clear;
        SQL.Add('select MD003,MD006 from BOMMD where MD001=:NN');
        parameters[0].Value:=s;
        open;
        ACTIVE;
        first;
        while not eof do
        begin
          new(p);
          p^.tcaption:=QR.fieldbyname('MD003').AsString;
          P^.num:=QR.fieldbyname('MD006').AsInteger;
          TmpNode:=Items.AddChildObject(TNode,p^.tcaption,p);
          ShowTree(TmpNode,p.tcaption);//递归
          next;
        end;
      end;
      QR.free;
    end;
    然后在需要的时候调用该函数就可以了,例如:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      ShowTree(nil,'0102-73316000');
    end;
    上述为一展BOM树的实例(BOM结构以关系数据库结构存储)。
      

  9.   

    我的email是:[email protected], 给我一份谢谢
      

  10.   

    [email protected]    give me!