zoukankan      html  css  js  c++  java
  • DevExpress中GridControl的属性设置及动态绑定数据和全选取消全选

    View Code
    DevExpress中GridControl的属性设置
    1. 隐藏最上面的GroupPanel
    gridView1.OptionsView.ShowGroupPanel=false;

    2. 得到当前选定记录某字段的值
    sValue=Table.Rows[gridView1.FocusedRowHandle][FieldName].ToString();

    3. 数据只读
    gridView1.OptionsBehavior.Editable=false;

    4.不显示MasterDetailView
    gridView1.OptionsDetail.EnableMasterViewMode=false;

    5.修改最上面的GroupPanel内容
    gridView1.GroupPanelText="CSDN";

    6.数据绑定:
    FieldName --数据库的字段名称

    7.读写拷贝权限设置
    ColumnView.Editable
    This property returns a value of the ColumnViewOptionsBehavior.Editable option
    不可写
    ColumnViewOptionsBehavior.Editable
    Gets or sets whether end users are allowed to invoke cell editors
    可读可写
    OptionsColumn.AllowEdit
    Gets or sets whether end users are allowed to invoke editors for the column's cells.
    可读可写
    只有ColumnViewOptionsBehavior.Editable=True 设置OptionsColumnAllowEdit 才有意义。
    OptionsColumn.ReadOnly
    Gets or sets whether end-users are prevented from editing the column's cell values.
    可读可写
    只读不可拷贝:
    ColumnViewOptionsBehavior.Editable = False
    只读可拷贝:
    ColumnViewOptionsBehavior.Editable = True
    OptionsColumn.AllowEdit = True
    OptionsColumn.ReadOnly = True
    可编辑:
    ColumnViewOptionsBehavior.Editable = True
    OptionsColumn.AllowEdit = True
    OptionsColumn.ReadOnly = False
    获取选中行的值
    代码:private void gridData_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
    {
    _id=GWEntLib.Utilities.Mix.ConvertUtils.ToInt32(gridData.GetRowCellValu(e.FocusedRowHandle, "Id"));
    _emrFileReadList = EMRTemplateFileReadList.GetEMRTemplateFileReadList(_id);
    gridVersonData.DataSource = _emrFileReadList;
    }
    响应事件:FocusedRowChanged
    获取字段值:gridData.GetRowCellValue(e.FocusedRowHandle, "Id")
    注意:FocusedRowChanged是Gridview的事件而不是gridControl的事件
    gridControl与Gridview的区别:前者是容器,后者为视图
    全选/取消全选
    private void Form1_Load(object sender, EventArgs e)
    {
    String str =@”
    select cast( 0 as bit ) 选择,ID,Name From dbo.Info”
    DataTable dt =new DataTable();
    dt =SqlHelper.ExecuteDataset(str).Tables[0];
    gridView.DataSource =dt;

    }
      #region 全选
    private void tsbSelectAll_Click(object sender, EventArgs e)
    {
    for (int i = 0; i < gridView.RowCount; i++)
    {
    gridView.SetRowCellValue(i,gridView.Columns.ColumnByFieldName("选择"), true);
    }


    }
    #endregion

    #region 取消全选
    private void tsbUnSelectAll_Click(object sender, EventArgs e)
    {
    for (int i = 0; i < gridView.RowCount; i++)
    {
    gridView.SetRowCellValue(i, gridView.Columns.ColumnByFieldName("选择"), false);
    }

    }

    #endregion
  • 相关阅读:
    CF1208C
    CF1208B
    CF1208A
    CF1206A
    wqy的C题
    wqy的B题
    [POI2005]SAM-Toy Cars
    Gym
    操作系统学习---进程
    C++多线程(POSIX)
  • 原文地址:https://www.cnblogs.com/songjiali/p/2331020.html
Copyright © 2011-2022 走看看