zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    三种空格unicode(u00A0,u0020,u3000)表示的区别
    python调用C++之pybind11入门(相互调用)
    基于go手动写个转发代理服务
    git rebase VS git merge
    外挂
    C#本地修改器
    C# 人工智能开源库生物特征
    深层信念网络
    ASP.NET CORE(C#)与Spring Boot MVC(JAVA)
    Net UI Spy工具:ManagedSpy
  • 原文地址:https://www.cnblogs.com/xihong2014/p/14642230.html
Copyright © 2011-2022 走看看