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自带的强大许多 ...
随机推荐
- Python cx_Oracle 安装小记
因为我的个人网站 restran.net 已经启用,博客园的内容已经不再更新.请访问我的个人网站获取这篇文章的最新内容,Python cx_Oracle 安装小记 SQLAlchemy 是 Pytho ...
- Delphi中Chrome Chromium、Cef3学习笔记(一)
原文 http://blog.csdn.net/xtfnpgy/article/details/46635225 官方下载地址:https://cefbuilds.com/ CEF简介: 嵌入 ...
- Python3 复制和深浅copy
赋值: 列表的赋值: list1 = ['peter','sam'] list2 = list1 print(list1,id(list1)) print(list2,id(list2)) list1 ...
- Eclipse 如何查看源代码
Eclipse 关联源代码:
- 使用jQuery+huandlebars中with应用及with+this应用
兼容ie8(很实用,复制过来,仅供技术参考,更详细内容请看源地址:http://www.cnblogs.com/iyangyuan/archive/2013/12/12/3471227.html) w ...
- MFC笔记4
1.添加图片 1)静态加载图片,直接在resourceView中控件设置就可以以实现 2)动态加载时,按照鸡啄米的教程http://www.jizhuomi.com/software/193.html ...
- python--第十天总结(线程、进程和协程)
Python线程 Threading用于提供线程相关的操作,线程是应用程序中工作的最小单元. #!/usr/bin/env python # -*- coding:utf-8 -*- import t ...
- Windows云服务器购买
一直点击下一步 支付
- spring整合mybatis在使用.properties文件时候遇到的问题
在spring里使用org.mybatis.spring.mapper.MapperScannerConfigurer 进行自动扫描的时候,设置了sqlSessionFactory 的话,可能会导致P ...
- 227. Basic Calculator II 无括号版本计算器
[抄题]: Implement a basic calculator to evaluate a simple expression string. The expression string con ...