delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
关于TTreeView添加节点的函数 VCL组件开发及应用
http://www.delphi2007.net/DelphiVCL/html/delphi_20061224095004158.html
procedure   TForm1.FindLeechDom(Leechdomname:   String;node:   TTreeNode);  
  var  
      temp:   TQuery;  
      node1:   TTreeNode;  
  begin  
      Try  
          temp   :=   TQuery.Create(Self);  
          temp.DatabaseName   :=   ExtractFilePath(Application.ExeName);  
          With   temp   do  
          begin  
              Close;  
              SQL.Clear;  
              SQL.Add('select   *   from   leechdom.db   where   上级编码   =   :Value');  
              ParamByName('value').AsString   :=   Leechdomname;  
              Open;  
          end;  
          while   Not   Temp.Eof   do  
          begin  
              node1   :=   TreeView1.Items.AddChild(node,temp.FieldByName('药品类别').AsString);  
              FindLeechDom(temp.FieldByName('药品类别').AsString,node1);  
              temp.Next;  
          end;  
      Finally  
          temp.Free;  
      end;  
  end;  
   
   
  为什么在FindLeechDom函数的声明里还能用FindLeechDom这个函数呢?  
  我都看不懂这段程序是什么意思?有没有高手解释一下??  
 

递归调用

谁能给我解释一下啊??  
   
  谢谢了

很明显递归调用

解释一下,这个程序好吗??  
   
  看不懂。

递归

。。。递归调用。。要看基础。

这是一个递归函数,是将数据库中的药品项目全部罗列出来了!  
  例如:1、外科类-分5种药,每种还可以再分N种,依次分下去。层次是不固定的,但是每个项目都有一个对应的父项目。最顶层的没有父项目

连递归都不懂,还做程序,趁早改行

递归  
   
   
  不过这样递归不好,  
  应该一次把数据取出来,  
  对本地DataSet遍历进行递归

procedure   TForm1.FindLeechDom(Leechdomname:   String;node:   TTreeNode);  
  var  
      temp:   TQuery;  
      node1:   TTreeNode;  
  begin  
      Try  
          temp   :=   TQuery.Create(Self);  
          temp.DatabaseName   :=   ExtractFilePath(Application.ExeName);  
          With   temp   do  
          begin  
              Close;  
              SQL.Clear;  
              SQL.Add('select   *   from   leechdom.db   where   上级编码   =   :Value');  
              ParamByName('value').AsString   :=   Leechdomname;  
              Open;  
          end;  
          while   Not   Temp.Eof   do  
          begin  
              node1   :=   TreeView1.Items.AddChild(node,temp.FieldByName('药品类别').AsString);  
              FindLeechDom(temp.FieldByName('药品类别').AsString,node1);   //添加当前node1的子节点  
              temp.Next;  
          end;  
      Finally  
          temp.Free;  
      end;  
  end;

posted on 2008-11-18 14:34 delphi2007 阅读(255) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。