Delphi控件cxGrid 如何动态创建列?
方法一:
var i: Integer;
Column: TcxGridDBColumn;
cxView: TcxGridDBTableView;
begin
cxView := Self.Levels[].GridView as TcxGridDBTableView;
if cxView.DataController.DataSource <> nil then
if cxView.DataController.DataSource.DataSet <> nil then
begin
cxView.ClearItems;
for i:= to cxView.DataController.DataSource.DataSet.FieldCount- do
begin
Column := cxView.CreateColumn;
Column.DataBinding.FieldName := cxView.DataController.DataSource.DataSet.Fields[i].FieldName;
Column.PropertiesClass := TcxTextEditProperties;
end;
end;
end;
方法一的补充
procedure CreateDynamicCols;
var
i, B_index: Integer;
begin
with BTVgather.Bands.Add do
begin
Caption := lcb1.Text;
Position.ColIndex := ;
end; for i := to dsgather.DataSet.FieldCount - do
begin
with BTVgather.Bands.Add do
begin
Position.BandIndex := ;
B_index := Index;
Caption := dsgather.DataSet.Fields[i].FieldName;
with BTVgather.CreateColumn do
begin
Position.BandIndex := B_index;
Caption := dsgather.DataSet.Fields[i].FieldName;
DataBinding.FieldName := dsgather.DataSet.Fields[i].FieldName;
PropertiesClassName := 'TcxCurrencyEditProperties';
TcxCurrencyEditProperties(Properties).DisplayFormat := ',0.00;-,0.00';
Width := 80;
//还可以绑定一个事件
OnGetDisplayText := Self.OnGetDisplayText;
end;
end;
end;
if BTVgather.Bands[].ChildBandCount = then
BTVgather.Bands[].Width :=
else
BTVgather.Bands[].Width := BTVgather.Bands[].ChildBandCount * ;
end;
方法二、
for i := to Query.FieldCount - do
begin
cxGrid.CreateColumn;
cxGrid.columns[i].DataBinding.FieldName := Query.Fields[i].DisplayName;
cxGrid.Columns[i].Caption := 'XXXX';
cxGrid.Columns[i].Width :=;
end;
方法三、
procedure TFrmRuleEdit.CreateCols;
var
Column: TcxGridDBColumn;
begin
cdsPowerPrj.First;
while not cdsPowerPrj.Eof do
begin
Column := viewPower.CreateColumn;
Column.Caption := cdsPowerPrj.FieldByName('description').Text;
Column.DataBinding.FieldName := cdsPowerPrj.FieldByName('powerName').Text;
Column.PropertiesClassName := 'TcxCheckBoxProperties';
Column.Width := ;
cdsPowerPrj.Next;
end;
end;
Delphi控件cxGrid 如何动态创建列?的更多相关文章
- DevExpres表格控件运行时动态设置表格列
本文是系列文章,陆续发表于电脑编程技巧与维护杂志. DevExpres产品是全球享有极高声誉的一流控件套包产品!国内典型用户包括:用友.金蝶.神州数码.工信部.中国石化.汉王科技等众多大中型科技型企业 ...
- cxgrid动态创建列
cxgrid动态创建列 procedure TFrmRuleEdit.CreateCols;varColumn: TcxGridDBColumn;begincdsPowerPrj.First;whil ...
- delphi控件属性大全-详解-简介
http://blog.csdn.net/u011096030/article/details/18716713 button 组件: CAPTION 属性 :用于在按钮上显示文本内容 Cancel ...
- DELPHI控件属性事件说明
常用DELPHI控件属性事件设置说明 常用DELPHI控件属性设置说明目录TForm Class TPanel组件 TToolBar Class TToolButton Class TTimer Cl ...
- Delphi 控件大全
delphi 控件大全(确实很全) delphi 控件查询:http://www.torry.net/ http://www.jrsoftware.org Tb97 最有名的工具条(ToolBar ...
- delphi 控件大全(确实很全)
delphi 控件查询:http://www.torry.net/ http://www.jrsoftware.org Tb97 最有名的工具条(ToolBar)控件库,仿Office97,如TDoC ...
- Winform开发框架之客户关系管理系统(CRM)的开发总结系列4-Tab控件页面的动态加载
在前面介绍的几篇关于CRM系统的开发随笔中,里面都整合了多个页面的功能,包括多文档界面,以及客户相关信息的页面展示,这个模块就是利用DevExpress控件的XtraTabPage控件的动态加载实现的 ...
- GridView控件RowDataBound事件中获取列字段值的几种途径
前台: <asp:TemplateField HeaderText="充值总额|账号余额"> <ItemTemplate> <asp:Label ID ...
- Ehlib(Delphi控件) v9.2.024 D7-XE10.2 免费绿色特别版
下载地址:https://www.jb51.net/softs/579413.html#downintro2 EHLib是一个DELPHI 下的非常棒的第三方Grid控件,比DELPHI自带的强大许多 ...
随机推荐
- ipv6无网络访问权限怎么办
有时IP4和IP6都正常连接,但突然又出现“IPV6无网络访问权限” 这是win7系统下经常发生的事情,如下图. 方法/步骤 1.IPV6没网络权限是正常的因为你没有IPV6的网络环境,那个只有部分教 ...
- @Bean 的用法
@Bean是一个方法级别上的注解,主要用在@Configuration注解的类里,也可以用在@Component注解的类里.添加的bean的id为方法名 定义bean 下面是@Configuratio ...
- C# 对Excel操作与分析
今天帮现在饿公司写个工具,要动态读excel上的ip地址与端口号,来更改IE的代理地址,由于好久没写Excel的操作了,只能查阅以前的项目,总结一下: 首先我们要引用我们的com接口的excelMic ...
- Halcon旋转图片的研究
在Halcon中有两个用于图像旋转的函数: 1,rotate_image *Image和ImageRotate分别是输入和输出图像 *Phi是输入的旋转度数 *interpolation是内插方式,默 ...
- [leetcode]2. Add Two Numbers.cpp
You are given two non-empty linked lists representing two non-negative integers. The digits are stor ...
- Fragment的粗浅理解
Fragment: 1.它是对于Activity界面实现的一种途径,相对于已经绑定的Layout,他更轻便,更灵活,更具有自由度和可设计性. 2.Fragment的功能正如他的正文意思所言,他是一个片 ...
- [C语言]进阶|数据类型: 整数, 浮点, 逻辑, 类型转换和条件运算
--------------------------------------------------------------------------------- [C语言的类型] 1. 整型(都分为 ...
- oracle中文乱码的解决方法
select userenv('language') from dual; NLS_LANG AMERICAN_AMERICA.AL32UTF8
- 性感天才黑客乔治·霍兹George Hotz 17岁打脸乔布斯20岁搞疯索尼
1.国内外著名黑客信息 1) 国外著名黑客 George Hotz 乔治·霍兹(George Hotz,1989年10月2日-),美国学生,2007年8月解锁苹果(Apple)iPhone手机,使得i ...
- 最新WordConut
一.代码地址:https://gitee.com/cainiaoY/WordCount 二.项目分析:代码根据实现的功能不同分为两个模块,一个wcFuctiong类,一个wcTest类,其中wcFuc ...