首页 技术 正文
技术 2022年11月21日
0 收藏 350 点赞 4,732 浏览 1013 个字

1. RepositoryItemCheckEdit默认有三种状态,选中状态、未选中状态和半选中状态(半选中状态通常用在TreeList中如果父节点下的子节点有选中的有未选中的,则父节点状态为半选中状态)。如果RepositoryItemCheckEdit所在的列未绑定数据源,那么该列默认只可以单选;如果绑定了数据源,那么可以同时多选。

2. 问题描述:

DevExpress XtraGrid RepositoryItemCheckEdit 复选框多选的解决方法

上述描述的ColumEdit关联FieldName数据源,但是在设计功能中并不仅仅这样就可以同时多选,还是选中后,在Grid其他的位置再单击鼠标,选中状态还是变为非选中。

DevExpress XtraGrid RepositoryItemCheckEdit 复选框多选的解决方法

在”是否需要协助”该类是一个复选框,那怎样才能实现多选的功能,选中之后不会点击其他地方又自动消失选中状态呢?
3.解决方法

这时需要我们为这个字段关联一个事件,事件代码如下:

private void repositoryItemCheckEdit1_QueryCheckStateByValue(object sender, DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e)
{
string val = "";
if (e.Value != null)
{
val = e.Value.ToString();
}
else
{
val = "False";//默认为不选
}
switch (val)
{
case "True":
case "Yes":
case "":
e.CheckState = CheckState.Checked;
break;
case "False":
case "No":
case "":
e.CheckState = CheckState.Unchecked;
break;
default:
e.CheckState = CheckState.Checked;
break;
}
e.Handled = true;
}

接下来为这个复选框字段进行关联事件

 this.repositoryItemCheckEdit1.QueryCheckStateByValue += new DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventHandler(this.repositoryItemCheckEdit1_QueryCheckStateByValue);

接下来运行程序RepositoryItemCheckEdit这个字段就可以实现多选的功能啦!

DevExpress XtraGrid RepositoryItemCheckEdit 复选框多选的解决方法

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,076
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,812
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,894