如何使得cxDBTreeList的节点内容可以多行显示? 如何使得cxDBTreeList的节点内容可以多行显示?如下图 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一上午的时间都没搞定这个小问题,试了cxDBTreeList和cxDBTreeListColumn的好多属性都没成功,发现TcxDBTreeListColumn.Properies的memo的TcxMemoProperties类有IsMultLine函数,但该函数是protected类型的。所以就在unit中扩展了一下type TcxMemoPropertiesEx:=Class(TcxMemoPropertiesEx);procedure TForm1.btn1Click(Sender: TObject);begin TcxMemoPropertiesEx(cxDBTreeListColumn1).isMultiline;end;结果还是不成功。希望牛人们出来指点一下!j 你要的功能不是多行显示而是多列显示吧,cxDBTreeList主要有以下三个关键属性KeyFields: 子节点ID DisplayFields:节点内容这里就是显示内容,记得可以在界面上直接新增的,应该是双击cxDBTreeList吧 ParentFields:父节点ID 我要的是多行显示,只需要一个列,但是如果cxDBTreeList的宽度不够的时候,node的内容就会多行显示,你看一下我发的图片的最后一个节点,它就是分成了两行显示的,因为cxDBGridList的宽度不足以让他单行显示全部了。 cxDBTreeList中,要使得某列的文本能折行显示:第一、将该列的Properties设置为Memo;第二、在Properties里的WordWrap设置为True。 ......var Form1: TForm1;//本代码在Delphi7 + DevExpress.V28 下编译、运行通过。implementationuses Midaslib;//免发布Midas.dll(TClientDataSet使用需要)//ClientDataSet1中有ID(自增类型)、ptID(整型)、name(字符型)三个字段;//先想办法在ClientDataSet1中增加三笔记录://1,0, 中国软件研发联盟QQ群//2, 1, 广州佬抛砖引玉来了//3,2, 欢迎大家来群里交流交流//当然,你也可以使用你自己现成的其他数据库来校验下列代码。 //若有谬误处,请指正,谢。{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);var i:integer;begin ClientDataSet1.LoadFromFile('.\tmp.cds');//加载数据库 DataSource1.DataSet:=ClientDataSet1;//连结数据源 cxDBTreeList1.DataController.DataSource:=DataSource1;//连接TreeList cxDBTreeList1.Align:=alClient;//客满 cxDBTreeList1.OptionsView.Headers:=False;//隐藏表头 cxDBTreeList1.DataController.CreateAllItems;//建立数据列 cxDBTreeList1.DataController.KeyField:='id';//关联键字段 cxDBTreeList1.DataController.ParentField:='ptID';//宿主字段 cxDBTreeList1.Columns[2].PropertiesClass:=TcxMemoProperties;//设置为memo属性 cxDBTreeList1.Columns[2].Width:=120;//列宽120 cxDBTreeList1.OptionsView.ColumnAutoWidth:=False;//取消自动列宽 cxDBTreeList1.OptionsView.CellAutoHeight:=True;//行高自动适应 (cxDBTreeList1.Columns[2].Properties as TcxMemoProperties).WordWrap:=True;//折行显示 for i:=1 downto 0 do cxDBTreeList1.Columns[i].Visible:=false;//隐藏0、1列 cxDBTreeList1.FullExpand;//展开全部节点// cxDBTreeList1.FullCollapse;//合拢全部节点end;procedure TForm1.cxCheckBox1Click(Sender: TObject);//折行显示控制begin cxDBTreeList1.OptionsView.ColumnAutoWidth:=not cxCheckBox1.Checked; (cxDBTreeList1.Columns[2].Properties as TcxMemoProperties).WordWrap:=cxCheckBox1.Checked;end;procedure TForm1.cxCheckBox2Click(Sender: TObject);//表头显示控制begin cxDBTreeList1.OptionsView.Headers:=cxCheckBox2.Checked;end;...... 问题解决了,谢谢“我看见佛”和“广州仔”的帮助。问题的根本是,不但要设置第一、将该列的Properties设置为Memo;第二、在Properties里的WordWrap设置为True。还要设置第三、将cxDBTreelist的OptionsView->CellAutoHeight属性设置为True。(同时OptionsView->ColumnAutoHeight属性设置为False)这样就可以实现节点内容的自动折行显示了。 [转]做守候在这里的最后一个乞丐! Webbrowser控件的一些小问题 请问以下语句是使用那个*.pas 如何将Query中的记录移动到最后一条? frReport出错,解决即给分。 怎样注册ACCESS的ODBC? 谁用过WINEDT? 怎样把程序做成曲线图的样子? 关于BS的小问题 delphi ADOQuery1.OPEN第二次打开就死掉了 线程中动态创建控件的事件 边接收数据边显示,如何考虑线程同步和安全问题?
试了cxDBTreeList和cxDBTreeListColumn的好多属性都没成功,
发现TcxDBTreeListColumn.Properies的memo的TcxMemoProperties类有IsMultLine函数,但该函数是protected类型的。所以就在unit中扩展了一下type
TcxMemoPropertiesEx:=Class(TcxMemoPropertiesEx);procedure TForm1.btn1Click(Sender: TObject);
begin
TcxMemoPropertiesEx(cxDBTreeListColumn1).isMultiline;
end;
结果还是不成功。希望牛人们出来指点一下!j
DisplayFields:节点内容这里就是显示内容,记得可以在界面上直接新增的,应该是双击cxDBTreeList吧
ParentFields:父节点ID
我要的是多行显示,只需要一个列,但是如果cxDBTreeList的宽度不够的时候,node的内容就会多行显示,你看一下我发的图片的最后一个节点,它就是分成了两行显示的,因为cxDBGridList的宽度不足以让他单行显示全部了。
第一、将该列的Properties设置为Memo;
第二、在Properties里的WordWrap设置为True。
var
Form1: TForm1;//本代码在Delphi7 + DevExpress.V28 下编译、运行通过。
implementationuses Midaslib;//免发布Midas.dll(TClientDataSet使用需要)//ClientDataSet1中有ID(自增类型)、ptID(整型)、name(字符型)三个字段;
//先想办法在ClientDataSet1中增加三笔记录:
//1,0, 中国软件研发联盟QQ群
//2, 1, 广州佬抛砖引玉来了
//3,2, 欢迎大家来群里交流交流//当然,你也可以使用你自己现成的其他数据库来校验下列代码。
//若有谬误处,请指正,谢。{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
ClientDataSet1.LoadFromFile('.\tmp.cds');//加载数据库
DataSource1.DataSet:=ClientDataSet1;//连结数据源
cxDBTreeList1.DataController.DataSource:=DataSource1;//连接TreeList
cxDBTreeList1.Align:=alClient;//客满
cxDBTreeList1.OptionsView.Headers:=False;//隐藏表头
cxDBTreeList1.DataController.CreateAllItems;//建立数据列
cxDBTreeList1.DataController.KeyField:='id';//关联键字段
cxDBTreeList1.DataController.ParentField:='ptID';//宿主字段
cxDBTreeList1.Columns[2].PropertiesClass:=TcxMemoProperties;//设置为memo属性
cxDBTreeList1.Columns[2].Width:=120;//列宽120
cxDBTreeList1.OptionsView.ColumnAutoWidth:=False;//取消自动列宽
cxDBTreeList1.OptionsView.CellAutoHeight:=True;//行高自动适应
(cxDBTreeList1.Columns[2].Properties as TcxMemoProperties).WordWrap:=True;//折行显示
for i:=1 downto 0 do cxDBTreeList1.Columns[i].Visible:=false;//隐藏0、1列
cxDBTreeList1.FullExpand;//展开全部节点
// cxDBTreeList1.FullCollapse;//合拢全部节点
end;procedure TForm1.cxCheckBox1Click(Sender: TObject);//折行显示控制
begin
cxDBTreeList1.OptionsView.ColumnAutoWidth:=not cxCheckBox1.Checked;
(cxDBTreeList1.Columns[2].Properties as TcxMemoProperties).WordWrap:=cxCheckBox1.Checked;
end;procedure TForm1.cxCheckBox2Click(Sender: TObject);//表头显示控制
begin
cxDBTreeList1.OptionsView.Headers:=cxCheckBox2.Checked;
end;
......
第一、将该列的Properties设置为Memo;
第二、在Properties里的WordWrap设置为True。
还要设置
第三、将cxDBTreelist的OptionsView->CellAutoHeight属性设置为True。
(同时OptionsView->ColumnAutoHeight属性设置为False)这样就可以实现节点内容的自动折行显示了。