• GridControl常用操作


    显示分组面板

    gridView1.OptionsView.ShowGroupPanel = true;

    是否开启多选

    gridView1.OptionsSelection.MultiSelect = true;

    多选模式(开启多选生效),行选择、单元格选择,CheckBox选择

    //单元格选择
    gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CellSelect;
    //整行选择
    gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
    //CheckBox选择
    gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;

    CheckBox列宽

    gridView1.OptionsSelection.CheckBoxSelectorColumnWidth = 30;

    获取CheckBox选中行索引

    int[] index = gridView1.GetSelectedRows();
    foreach (var item in index)
    {
       MessageBox.Show(item.ToString());
    }

    选中行索引

    gridView1.GetSelectedRows()[0]

     列宽自动调整

    gridView1.OptionsView.ColumnAutoWidth = true;

    行高自动调整

    gridView1.OptionsView.RowAutoHeight = true;

     是否开启编辑

    gridView1.OptionsBehavior.Editable = true;

    编辑模式

    //默认编辑模式,点击鼠标单元格可直接修改
    gridView1.OptionsBehavior.EditingMode = DevExpress.XtraGrid.Views.Grid.GridEditingMode.Default;
    //弹出窗口编辑
    gridView1.OptionsBehavior.EditingMode = DevExpress.XtraGrid.Views.Grid.GridEditingMode.EditForm;
    //当前点击行下方弹出编辑面板
    gridView1.OptionsBehavior.EditingMode = DevExpress.XtraGrid.Views.Grid.GridEditingMode.EditFormInplace;
    //隐藏当前行,出现编辑面板
    gridView1.OptionsBehavior.EditingMode = DevExpress.XtraGrid.Views.Grid.GridEditingMode.EditFormInplaceHideCurrentRow;
    //默认编辑模式,点击鼠标单元格可直接修改
    gridView1.OptionsBehavior.EditingMode = DevExpress.XtraGrid.Views.Grid.GridEditingMode.Inplace;

    获取点击单元格值

    private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
    {
        MessageBox.Show(e.CellValue.ToString());
    }

    获取选中行某一列数据

    private void gridView1_RowClick_1(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
    {
        string str = gridView1.GetRowCellValue(gridView1.GetSelectedRows()[0], "RegionDescription").ToString();
        MessageBox.Show(str);
    }
  • 相关阅读:
    [每日一题系列] LeetCode 1071. 字符串的最大公因子
    [每日一题系列] LeetCode 1013. 将数组分成和相等的三个部分
    git diff (19)
    WinDbg探究CLR底层(1)
    使用LINQ、Lambda 表达式 、委托快速比较两个集合,找出需要新增、修改、删除的对象
    转MySQL遇到的语法差异及解决方案
    批量拼脚本神器-NimbleText
    Visual Studio 2017中使用正则修改部分内容
    如何使用ILAsm与ILDasm修改.Net exe(dll)文件
    在Windows上安装Elasticsearch v5.4.2
  • 原文地址:https://www.cnblogs.com/liessay/p/12712273.html
Copyright © 2020-2023  润新知