DevExpress GridControl使用教程:之 添加 checkbox 复选框

 

 

 

添加一列,FieldName为"FLAG",将ColumnEdit设置为复选框样式

gridview1   =》optionsbehavior =》  editable设置为true   (如果自己定义全选,取消全选此处可以设置false)

将要绑定的DataTable添加列"FLAG",Type为bool。

gridview1   =》columnEdit => new =》checkEdit 

此时就会出现复选框 但是 复选框 无法选择 需要继续 给 gridView 添加

点击事件  RowCellClick

private void gv_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
{
int index = this.gv.FocusedRowHandle;
selStudent = gv.GetRow(index) as StudentDTO;
if (selStudent == null)
{
FrmAlert.ShowMessageBoxErrorDialog(this, "请选中一行!");
return;
}
if (e.Column.Tag.ToSafeString() == "checkbox")
{
int selectIndex = this.gv.FocusedRowHandle;
StudentDTO row = this.gv.GetRow(selectIndex) as StudentDTO;
if (row != null)
{
DevExpress.Data.CustomSummaryEventArgs e1 = new DevExpress.Data.CustomSummaryEventArgs();
row.Flag = !row.Flag;
}
this.gv.RefreshData();
}
}

获取:

string value = gridview.GetDataRow(i)["FLAG"].toString();

value == "true" ||  "" ("false")

设置为多选

gridView1 .OptionsSelection.MultiSelect = true;

gridView1 .OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;

 

代码如下 :

 注意:Tag 显示在下图

 

转载于:https://www.cnblogs.com/struggle-cs/p/9184661.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值