cxGrid之checkbox小结
http://www.cnblogs.com/Kim53622744/p/4428997.html
在cxgrid中增加选择列
1、在dataset(query/table/clientdataset etc.)fieldeditor中增加计算字段fdSelect,datatype 为string,当然也可以其它类型。fieldkind设为fkCalculated或fkInternalCalc;设为fkInternalCalc时,应当注意在选择语句如下写:select '0' as fdselect,* from tableA,否则会报field "***" not found。设为fkCalculated时,不需要改变原语句。
object strngfldWaitInfdselect: TStringField
FieldKind = fkInternalCalc
FieldName = 'fdselect'
end
2、cxgrid DbTableView中增加列cxgrdbclmnSelect,设置Properties为checkbox,具体设置如下:
object cxgrdbclmnSelect: TcxGridDBColumn
Caption = #36873#25321
DataBinding.FieldName = 'fdSelect'
PropertiesClassName = 'TcxCheckBoxProperties'
Properties.DisplayGrayed = 'nssUnchecked'
Properties.ValueChecked = '1'
Properties.ValueGrayed = 'nssUnchecked'
Properties.ValueUnchecked = '0'
MinWidth = 25
Options.Editing = False //重要,许多朋友讲到,不响应cellClick事件,设为false后就可响应。
Options.Filtering = False
Options.IncSearch = False
end
3、根据需要在CellClick或mouseup中增加代码
var
row: Integer;
begin
if cxgrdbtblvwGrid1DBTableView1.ViewData.RecordCount = 0 then
Exit;
row := cxgrdbtblvwGrid1DBTableView1.DataController.FocusedRowIndex;
if cxgrdbtblvwGrid1DBTableView1.ViewData.Records[row].Values[0] = '1' then
cxgrdbtblvwGrid1DBTableView1.ViewData.Records[row].Values[0] := '0'
else
cxgrdbtblvwGrid1DBTableView1.ViewData.Records[row].Values[0] := '1';
end;
4、f9看下效果。
PS:fkCalculated与fkInternalCalc
Fields calculated by SQL servers or the Borland Database Engine to display the results of a query that returns a live dataset have a FieldKind of fkInternalCalc, not fkCalculated. This is because the field values are stored in the dataset. Calculated fields in a client dataset that are calculated in an event handler but stored in the dataset also have a FieldKind of fkInternalCalc instead of fkCalculated. Unlike regular calculated fields, internally calculated fields can be used in filter expressions. They can be edited, but the changes are discarded. To prevent editing, set the property to true.
Delphi cxgrid 使用方法
1.绑定数据
方法
cxGrid1DBTableView1.DataController.DataSource:=DataSource1
2.去掉"Drag a column header here to group by that column"
方法
cxGrid1DBTableView1.OptionsView.GroupByBox置为False
3.去掉表头下三角数据
方法
cxGrid1DBTableView1.Optionscustomize.columnfiltering置为False
4.增加序号
方法
在dataset 里边增加 Mycount 字段 类型为 string
在 CXgrid 增加显示字段 序号 mycount
为该字段写事件
procedure Tfrm_form.ReDataSet2mycountGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
inherited;
text:=inttostr(redataset2.RecNo);
end;
将 序号 绑定 字段 Mycount
5.CXgrid 增加一栏显示checkBox
方法
在dataset 里边增加 MySelect字段 类型为 BOOLEAN
在 CXgrid 增加显示字段 选择 select
设定select 字段的Properties为 CheckBox . ReadOnly = False;
NullStyle = nssUnchecked
procedure Tfrm_form.cxGrid1DBTableView1CellClick(
Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
Row: Integer;
begin
inherited;
if ACellViewInfo.Item.Name = 'mycheck' then
begin
Row := cxGrid1DBTableView1.DataController.FocusedRecordIndex;
if cxGrid1DBTableView1.ViewData.Records[Row].Values[0] = True then
cxGrid1DBTableView1.ViewData.Records[Row].Values[0] := False
else
cxGrid1DBTableView1.ViewData.Records[Row].Values[0] := True;
end;
end;
procedure Tfrm_form.cxGrid1DBTableView1MouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Row: Integer;
begin
inherited;
//单选
// for Row:=0 to cxGrid1DBTableView1.DataController.RecordCount-1 do
// begin
// cxGrid1DBTableView1.ViewData.Records[Row].Values[0] := False;
// end;
//多选
if cxGrid1DBTableView1.DataController.RecordCount<>0 then
begin
Row := cxGrid1DBTableView1.DataController.FocusedRecordIndex;
if cxGrid1DBTableView1.ViewData.Records[Row].Values[0] = True then
cxGrid1DBTableView1.ViewData.Records[Row].Values[0] := False
else
cxGrid1DBTableView1.ViewData.Records[Row].Values[0] := True;
end;
end;
cxGrid之checkbox小结的更多相关文章
- cxGrid增加一栏显示checkBox的设置方法
鉴于本人首次设定cxGrid的CheckBox的时候费了很大劲,发现很多人都会碰到这个问题,现在总结一下,以供各位互相学习借鉴. 步骤如下(不分先后): 1. cxGrid添加完自己所需的所有字段后, ...
- Delphi - cxGrid设定字段类型为CheckBox
cxGrid设定字段类型为CheckBox 1:设定OraQuery属性 CachedUpdates设定为True: 双击打开OraQuery,选中Update SQLs页面,Insert.Updat ...
- checkbox在vue中的用法小结
关于checkbox多选框是再常见不过的了,几乎很多地方都会用到,这两天在使用vue框架时需要用到checkbox多选功能,实在着实让我头疼,vue和原生checkbox用法不太一样,之前对于vue插 ...
- 关于 cxGrid 的过滤问题
http://bbs.csdn.net/topics/390536919 关于 cxGrid 的过滤问题 [问题点数:20分,结帖人zhengyc653] 不显示删除回复 ...
- DevExpress控件的GridControl控件小结
DevExpress控件的GridControl控件小结 (由于开始使用DevExpress控件了,所以要点滴的记录一下) 1.DevExpress控件组中的GridControl控件不能使横向滚动条 ...
- delphi cxgrid 使用方法
delphi cxgrid 使用方法1.绑定数据 方法 cxGrid1DBTableView1.DataController.DataSource:=DataSource12.去掉"Drag ...
- cxGrid的使用方法
来源 http://www.cnblogs.com/djcsch2001/archive/2010/07/19/1780573.html 1. 去掉GroupBy栏 cxGrid1DBTable ...
- android基础小结
(注:此小结文档在全屏模式下观看效果最佳) 2016年3月1日,正式开始了我的android学习之路. 最最开始的,当然是学习怎样搭载环境了,然而苦逼的我在win10各种坑爹的指引下还是安装了一个星期 ...
- 1:CSS中一些@规则的用法小结 2: @media用法详解
第一篇文章:@用法小结 第二篇文章:@media用法 第一篇文章:@用法小结 这篇文章主要介绍了CSS中一些@规则的用法小结,是CSS入门学习中的基础知识,需要的朋友可以参考下 at-rule ...
随机推荐
- if __name__ == '__main__的理解
模块之间引用不能循环成环,圆圈 模块的收搜 !!!把模块当作脚本执行 什么叫模块:py文件,如果一个py文件被导入了,他就是一个模块, 模块没有具体的调用过程 但是能对外提供功能 什么叫脚 ...
- Centos PS1
PS1="[\[\e[35m\]\u\[\e[m\]\[\e[31m\]->\[\e[m\]\[\e[33m\]\H\[\e[m\]\[\e[31m\]->\[\e[m\]\[\ ...
- vue中$ref的基本用法
1.使用在一般的标签上 <div id="app"> <input ref="count" type="text" v-m ...
- Notepad++语言格式设置,自定义扩展名关联文件格式
简单粗暴--直接上图
- 关于 construct object opp
constructor 定义和用法 constructor 属性返回对创建此对象的数组函数的引用. 语法 object.constructor 实例 例子 1 在本例中,我们将展示如何使用 const ...
- @Transactional注解使用心得
配置基于注解的声明式事务: ...配置tx,aop的命名空间 xmlns:tx="http://www.springframework.org/schema/tx" xmlns:a ...
- 如何在Android平台上使用USB Audio设备
http://blog.csdn.net/kevinx_xu/article/details/12951131 需求:USB Headset插上去后,声音要从本地CODEC切换到USB Headset ...
- 2018.12.22 bzoj3277: 串(后缀自动机+启发式合并)
传送门 跟这道题是一模一样的. 于是本蒟蒻又写了一遍10min1A庆祝 代码: #include<bits/stdc++.h> #define ri register int using ...
- SPRING 集成 KAFKA 发送消息
准备工作 1.安装kafka+zookeeper环境 2.利用命令创建好topic,创建一个topic my-topic 集成步骤 1.配置生产者 <?xml version="1.0 ...
- excel 错误提示以及其他基础知识
http://wenda.tianya.cn/question/05a3d11b0e4f3c34 For i = 1 To ActiveSheet.ChartObjects.Count M ...