一、导出EXCEL   TXT   HTML:

uses cxTLExportLink;

cxExportTLToEXCEL(dm.SaveDialog.FileName,cxDBTreeList1,TRUE,TRUE);  //轉入EXCEL
cxExportTLToTEXT(dm.SaveDialog.FileName,cxDBTreeList1,TRUE,TRUE);     //轉入TXT
cxExportTLToHTML(dm.SaveDialog.FileName,cxDBTreeList1,TRUE,TRUE);     //轉入HTML

---------------------------------------------------------------------------------------------------------------

二、cxdbtreelist1共多少条记录:     showmessage(inttostr(cxtreelist1.VisibleCount));

cxdbtreelist1当前记录的索引:  showmessage(inttostr(cxTreeList1.FocusedNode.VisibleIndex));

cxdbtreelist1有多少列:             showmessage(inttostr(cxtreelist1.VisibleColumnCount));

cxdbtreelist1当前记录的层级:   showmessage(inttostr(cxTreeList1.FocusedNode.Level));

cxdbtreelist1自动展开:             cxtreelist1.fullexpand; //自动展开

cxdbtreelist1自动折叠 :               cxtreelist1.FullCollapse;

cxdbtreelist1取上级节点内容:   ShowMessage(cxdbTreeList1.FocusedNode.Parent.Values[0]);

三、新增、删除结点:

增加同级结点:

procedure Tfr_bommglin.cxButton1Click(Sender: TObject);
var node:TcxTreeListNode;
begin

node:=cxdbTreeList1.FocusedNode.Parent.AddChild;
   node.Values[0]:='aaaaa';
   node.Values[1]:=node.Level;

end;

增加下级节点:

procedure Tfr_bommglin.cxButton2Click(Sender: TObject);
var node:TcxTreeListNode;
begin
   node:=cxdbTreeList1.FocusedNode.AddChild;       //增加子节点在首记录:cxdbTreeList1.FocusedNode.AddChildFirst;
   node.Values[0]:='aaaaa';
   node.Values[1]:=node.Level+1;
   cxdbTreeList1.FocusedNode.Expanded:=true;  //展开子节点
end;

删除节点:

ClientDataSet1.GetBookmark;
cxdbTreeList1.FocusedNode.Delete;     //删除当前节点记录;删除当前节点的子节点:cxdbTreeList1.FocusedNode.DeleteChildren;
cxDBTreeList1.DataController.GotoBookmark;

多节点选择删除:

cxDBTreeList1.DeleteSelection

数据集控制:

cxDBTreeList1.DataController.dataset.GotoFirst; //GotoLast     gotonext    gotoprev   GotoBookmark

cxDBTreeList1.DataController.dataset.Append;         //cancel      updatedata

cxDBTreeList1.DataController.dataset.edit;

根据cxdbtreelist随clientdataset1记录定位:

首先:bl:=cxDBTreeList1.DataController.DataSet.GetBookmark;

接着:cxDBTreeList1.DataController.DataSet.GotoBookmark(bl);
          cxDBTreeList1.SetFocus;

多结点选择取记录:

for i:=0 to cxDBTreeList1.SelectionCount-1 do
     begin
       ShowMessage(cxDBTreeList1.Selections[i].Values[1]);
    end;

-------------------------------------------------------------------------------------------

三、增加节点图片:

先在窗体上放ImageList关联到cxDBTreeList,在cxDBTreeList的GetNodeImageIndex事件中写如下:

procedure cxDBTreeList1GetNodeImageIndex(Sender:TcxCustomTreeList; ANode: TcxTreeListNode; AIndexType:
                       TcxTreeListImageIndexType; var AIndex: TImageIndex);
 var
    i :Integer;
  begin
    //给树结点加上图标
    for i := 0 to ANode.ValueCount do
      begin
     if ANode.Level = 0 then
         begin
           ANode.ImageIndex := 0;
         end
       else
       if ANode.Level = 1 then
         begin
           ANode.ImageIndex := 2;
         end
       else
       if ANode.Level = 2 then
         begin
           ANode.ImageIndex := 1;
         end;
     end;
 end;


实现 cxTreeList使用复选框实现多选 自动级联选择

var
RootNode,SonNode:TcxTreeListNode;
qryRoot,qrySon:TADOQuery; cxTreeList1.OptionsView.CheckGroups:=true;
cxTreeList1.Root.CheckGroupType:=ncgCheckGroup;
qryRoot:=TAdoQuery.create(nil);
qrySon:=TAdoQuery.create(nil);
qryRoot.Connection:=con1;
qrySon.Connection:=con1;
try
with qryRoot do
begin
Close;
SQL.Text:='SELECT DISTINCT PID,Caption FROM dbo.Parent';
Open;
qrySon.Close;
qrySon.SQL.Text:='SELECT PID,SID,Caption FROM dbo.Son ORDER BY PID,SID';
qrySon.Open;
cxTreeList1.Clear;
DisableControls;
while not eof do
begin
RootNode:=cxTreeList1.Add;
RootNode.CheckGroupType:=ncgCheckGroup;
RootNode.Texts[0]:=FieldByName('PID').AsString+'.'+FieldByName('Caption').AsString;
RootNode.Texts[1]:=FieldByName('PID').AsString;
RootNode.Enabled:=False;
with qrySon do begin DisableControls;
Filtered:=False;
Filter:='PID='+QuotedStr(FieldByName('PID').AsString);
Filtered:=True;
while not Eof do
begin
SonNode:=RootNode.AddChild;
SonNode.Texts[0]:=trim(FieldByName('SID').AsString)+'.'+FieldByName('Caption').AsString;
SonNode.Texts[1]:=trim(FieldByName('SID').AsString);
Next;
end;
EnableControls;
end;
Next;
end;
EnableControls;
end;
finally
qryRoot.Free;
qrySon.Free;
end;

  


获取CxDBTreeList所有父节点

function  ShowCxDBTreeListNodeValues(ACxDBTreeList: TcxDBTreeList): string; 
var 
S:string; 
aNode:TcxTreeListNode; 
i:Integer; 
begin 
  if ACxDBTreeList.Visible then 
    if ACxDBTreeList.FocusedNode.HasChildren then //只显示最底层,如果要显示全部  去掉这个条件
     Exit; 
  aNode:=ACxDBTreeList.FocusedNode; 
  for i:=aNode.Level downto 0 do 
  begin 
  if i=ACxDBTreeList.FocusedNode.Level then 
    S:=aNode.Values[1] 
  else 
    S:=aNode.Values[1]+'->'+S; 
  aNode:=aNode.Parent; 
  Result:=S; 
  end; 
end;


1,在cxTreeList的treeview内添加的checkbox能否设置一下实现不联动? 我现在选中2,其子节点也全部被选中了,我想实现一个一个的单独可以选中,就是所有子节点全部被选中,其父节点也不跟随子节点的状态变化。 2,把cxTreeList某一列的properties的属性设置为RadioGroup,Items内只设置了一个值“允许” 我如何能动态设置RadioButton的选中状态? 当然properties的属性也可以设置为CheckBox,使用Newnode.Values[3] := False;就可以设置checkbox为非选中状态,但我是想学习一下RadioGroup的用法。

咋自动选中子节点的? 俺这儿想尽了办法都选不中子节点 大哥指点俺一下! 就是你那个联动咋弄上去的?

cxTreeList1.OptionsView.CheckGroups := True;  cxTreeList1.Root.CheckGroupType := ncgCheckGroup; var NewNode: TcxTreeListNode; begin   NewNode:=cxTreeList1.Add;   NewNode.CheckGroupType :=  ncgCheckGroup;

顶顶,再帮忙看看

帮忙看看,来个回复也好啊,如何让我结贴呢

CheckGroupType := ncgCheckGroup; 除了这种属性,还有另一种类似 RadioGroup的方式。

cxDBTreelist一些使用方法的更多相关文章

  1. DevExpress VCL 的 cxDBTreeList 的使用方法

    DevExpress VCL 的 cxDBTreeList 的使用方法:(假设控件名为: WBSTree) 1.控件WBSTree 通过绑定  DataSet 获取数据记录(Nodes),通过 Col ...

  2. javaSE27天复习总结

    JAVA学习总结    2 第一天    2 1:计算机概述(了解)    2 (1)计算机    2 (2)计算机硬件    2 (3)计算机软件    2 (4)软件开发(理解)    2 (5) ...

  3. mapreduce多文件输出的两方法

    mapreduce多文件输出的两方法   package duogemap;   import java.io.IOException;   import org.apache.hadoop.conf ...

  4. 【.net 深呼吸】细说CodeDom(6):方法参数

    本文老周就给大伙伴们介绍一下方法参数代码的生成. 在开始之前,先补充一下上一篇烂文的内容.在上一篇文章中,老周检讨了 MemberAttributes 枚举的用法,老周此前误以为该枚举不能进行按位操作 ...

  5. IE6、7下html标签间存在空白符,导致渲染后占用多余空白位置的原因及解决方法

    直接上图:原因:该div包含的内容是靠后台进行print操作,输出的.如果没有输出任何内容,浏览器会默认给该空白区域添加空白符.在IE6.7下,浏览器解析渲染时,会认为空白符也是占位置的,默认其具有字 ...

  6. 多线程爬坑之路-Thread和Runable源码解析之基本方法的运用实例

    前面的文章:多线程爬坑之路-学习多线程需要来了解哪些东西?(concurrent并发包的数据结构和线程池,Locks锁,Atomic原子类) 多线程爬坑之路-Thread和Runable源码解析 前面 ...

  7. [C#] C# 基础回顾 - 匿名方法

    C# 基础回顾 - 匿名方法 目录 简介 匿名方法的参数使用范围 委托示例 简介 在 C# 2.0 之前的版本中,我们创建委托的唯一形式 -- 命名方法. 而 C# 2.0 -- 引进了匿名方法,在 ...

  8. ArcGIS 10.0紧凑型切片读写方法

    首先介绍一下ArcGIS10.0的缓存机制: 切片方案 切片方案包括缓存的比例级别.切片尺寸和切片原点.这些属性定义缓存边界的存在位置,在某些客户端中叠加缓存时匹配这些属性十分重要.图像格式和抗锯齿等 ...

  9. [BOT] 一种android中实现“圆角矩形”的方法

    内容简介 文章介绍ImageView(方法也可以应用到其它View)圆角矩形(包括圆形)的一种实现方式,四个角可以分别指定为圆角.思路是利用"Xfermode + Path"来进行 ...

随机推荐

  1. c++ 分配与释放内存

    教学内容: calloc分配内存 calloc与malloc的区别 memset函数初始化内存 free释放动态分配的内存 一.calloc函数分配内存 void *calloc( size_t nu ...

  2. Java学习技术图

    最近,在研究docker,作为一个程序员,要想提高自己的竞争力,必须时刻保持学习的态度,技多不压身:发现从事Java工作以来,买了很多书,也逛了很多技术贴,技术的平面宽度是不断的延伸,有些是工作中需要 ...

  3. 并发系列(二)----Java内存模型

    一 简介 在并发编程中,两个线程(A.B)同时操作一个普通变量的时候会出现线程A在操作变量时线程B也将变量操作了,此时线程A是无法感知变量发生变化的,造成变量改变错误.更据以上例子我们需要解决的问题就 ...

  4. 使用Nmon_Analyzer excel 问题总结

    使用wps打开nmon的分析文件,出现  运行时错误13类型不匹配 查看具体代码,是这句出现错误Start = DateValue(Sheet1.Range("date")),进一 ...

  5. 《杜增强讲Unity之Tanks坦克大战》8-子弹碰撞处理

    8 子弹碰撞处理 为了处理子弹打到坦克的伤害我们在这里新建一个Shell.cs 子弹有两种情况,碰到坦克炸开,没有碰到坦克则过2s子弹销毁. void Start () { Destroy (game ...

  6. L2 Helios OPcodez

    天堂2 Helios太阳神版本 的客户端和服务端封包 *********************** Client ***********************00 SendLogOut01 Req ...

  7. 比较undefined和“undefined”

    说实话,它们之间的区别挺明显的,我们一般认为undefined是JavaScript提供的一个“关键字”,而“undefined”却是一个字符串,只是引号的内容和undefined一样. undefi ...

  8. Harbor 学习分享系列3 - Harbor用户指南

    云盘链接 链接:https://pan.baidu.com/s/1wvgI3KGGIckqzlkB-mYz4g 密码:doe7 通过本文无法把本文中的实验进行成功,请联系作者本人,作者会录制视频发送给 ...

  9. 《how tomcat works》阅读笔记 - 2 - 门面设计模式,避免强制转换

    在第二章 2.3节中 try { servlet = (Servlet) myClass.newInstance(); servlet.service((ServletRequest) request ...

  10. 笨办法学Python - 习题6-7: Strings and Text & More Printing

    目录 1.习题 6: 字符串(string) 和文本 2.加分习题: 3.我的答案 4.习题总结 5.习题 7: 更多打印 6.习题总结 1.习题 6: 字符串(string) 和文本 学习目标:了解 ...