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自带的强大许多 ...
随机推荐
- threading join用法
join():在子线程完成运行之前,这个子线程的父线程将一直被阻塞 import threading #线程import time def Beijing(n): print('Beijing tim ...
- hadoop分布式集群搭建(2.9.1)
1.环境 操作系统:ubuntu16 jdk:1.8 hadoop:2.9.1 机器:3台,master:192.168.199.88,node1:192.168.199.89,node2:192.1 ...
- 应用脚手架创建一个React项目
安装脚手架,这里会自动安装到你的nodejs里面 npm install create-react-app -g 进入创建目录 我这里创建一个为 react03的项目,等待下载..... create ...
- git clone Failed to connect to 127.0.0.1 port 43213: Connection refused
不知道为什么使用git clone 的时候报了上面的错误,后面发现是 127.0.0.1 port 43213的端口被代理占用了,可以这样查看: $ env|grep -i proxy 结果是: NO ...
- 关于extern的使用
学的时候不认真总结,用的时候就一堆bug. 上回也是调extern调了半天,今天又犯老毛病. data 比如说是要用到的的在main函数中不断刷新的量.那么这个unsigned int data 要写 ...
- 初学c# -- 开始学directx
这些天对directx有兴趣了,开始慢慢学,先学基础,找了好些资料,为毛都写的辣么长呢,学习精简下来就几行. 安装个directx sdk,在win10里面文件夹C:\Windows\Microsof ...
- AngularJS学习笔记(一)
一.基本指令 1.ng-app=" " 指令初始化一个 AngularJS 应用程序,定义angularJS的使用范围; tips:一个页面里创建多个 ng-app 手动加载即可: ...
- WordPress 自动初始化数据库
背景 自动化搭建开发环境.测试.部署如通过网页操作(访问 /wp-admin/install.php)相对比较麻烦且在有的场景无法实现. 步骤 修改 wp-config.php 配置 wordpres ...
- Django中操作Redis
一 创建redis连接池 redis_pool.py pool = redis.ConnectionPool(host='10.211.55.4', port=6379) 二 引入连接池 import ...
- 31.Mysql复制
31.Mysql复制复制是指将主数据库的DDL和DML操作通过二进制日志传到从数据库上,然后在从数据库上对重做日志,从而使从库与主库保持同步.Mysql支持一台主库同时向多台从库复制,从库也可以作为其 ...