TcxtreeList 装入代码

时间:2014-07-22 08:24:53
【文件属性】:

文件名称:TcxtreeList 装入代码

文件大小:1KB

文件格式:TXT

更新时间:2014-07-22 08:24:53

TcxtreeList 使用

CONST SName: ARRAY[0..3] OF STRING = ('xmmc', 'xmbm', 'gltw', 'tg'); procedure LoadTcxTReeList(Tree:Tcxtreelist;Qeytable:TAdoQuery;bm:string;SName:array of string); var level,firstlen,k,i:integer; mynode:array[0..9] of TcxTreeListNode;//存每层节点,最大十层 begin k:=Length(SName); tree.Clear; if Qeytable.RecordCount=0 then Exit; level:=0; Qeytable.First; Tree.BeginUpdate; firstlen:=Length(Qeytable[bm]);//第一层编码长度 mynode[level]:=tree.TopNode; //取根节点 while not Qeytable.Eof do //遍历数据表,利用编码字段记录排序规律,依次添加树节点 begin level:=(Length(Qeytable[bm])-firstlen) div 2; //第几层 if (level-1)<0 then mynode[level]:= tree.add(mynode[0],nil) else mynode[level]:= tree.addchild(mynode[level-1],nil); for i:=0 to k-1 do begin if not Qeytable.FieldByName(SName[i]).IsNull then mynode[level].Texts[Tree.ColumnByName(SName[i]).ItemIndex]:=Qeytable[sName[i]]; end; Qeytable.next; end; Tree.EndUpdate; mynode[0].expand(False); tree.Items[0].Selected := True; end;


网友评论

  • 非常不错,很好用!多谢