1:去除 GridView 头上的 "Drag a column header here to group by that column"

-->  点击 Run Designer  -> 找到:OptionView ->  将 ShowGroupPanel : 设置为 false ;

2:如何 显示出 GridView 自带的 搜索功能

-->  点击 Run Designer  ->  找到: OptionsFind -> 将AlwaysVisible : 设置为 True

3:如何 将GridView 的大小自适应窗体的大小

-->  右键 GridView 控件  -> 属性  ->  找到 Dock : 设置为 Fill

4:当GridView数据源发生变化时,如何更改GridView所"绑定的值"

Code 注 :  其实就是重新创建了一个GridView的实例。

1  gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView(gridControl1);
2 gridControl1.MainView = gridView1;
3 gridView1.OptionsView.ShowGroupPanel = false;
4 gridView1.OptionsFind.AlwaysVisible = true;
5 gridControl1.DataSource = dt;

5:在GridControl 中添加checkbox复选框

--> gridView -> run designer -> columns -> 添加一列(如果没有的话) 然后如图设置

-- >  另外当我们需要动态绑定grid数据时,DataTable 中列的名字要和我们在gridview中设置的FileName名字要移植,不然数据是显示不出来的。

6:让GridView 行 不可编辑

-- > Run Designer -> OptionsBehavior -> Editable :  False

7 : 在GridView 行中添加Button按钮

 1 public void ButtonInitial()
2 {
3 RepositoryItemButtonEdit rib = new RepositoryItemButtonEdit();
4 rib.TextEditStyle = TextEditStyles.HideTextEditor;
5 rib.Buttons[0].Kind = ButtonPredefines.Glyph;
6 rib.ButtonClick += rib_ButtonClick;
7 rib.Buttons[0].Caption = "详细信息";
8 rib.Buttons[0].Visible = true;
9 gridView1.Columns["DOWNSTATE"].ColumnEdit = rib;
10
11 }
12
13 void rib_ButtonClick(object sender, ButtonPressedEventArgs e)
14 {
15 int rowindex = gridView1.FocusedRowHandle;
16 DataRow row = gridView1.GetDataRow(rowindex);
17 }

8 : GirdView行添加Button按钮之后,触发事件不可用.

将GridView Editable 设置为True 让GridView可编辑,如果不想让它可编辑的话,在一列一列的进行设置.原因是:将GridView设置为不可编辑之后,那么鼠标点击Button那一列只是选中而已,不会进行触发事件.

9 : GridView 设置选中行的颜色

GridView : Run Designer ->  Appearences : selectRow & FocusedRow (两项都要设置)

BackColor :  MediumSlateBlue  背景色

 ForeColor :  White    前景色 字体颜色

10 :  GridView 设置标题行颜色

GridView : Run Designer -> Appearences : HeadPanel  在这个属性组中都是关于标题行的设置,再次不做诠释.

当设置完HeadPanel 其实并没有结束,是不显示效果的, 还需要设置 GridControl 属性中 LookAndFeel : Style 设置为ultraFlat , UseDefaultLookAndFeel  设置为 False .

11 :  GridView 设置标题行以及内容行 数据居中

标题行 10 所述 在HeadPanel 里有一个TextOptions  展开之后 将HAlignment :  Center

如果是将内容行数据居中.有两种方法 1 : 逐行设置  2 : 设置Appearences

1 : GridView -> Run Designer -> Columns  -> AppearanceCell ->  TextOptions 找到HAlignment :  Center .

2 : GridView -> Run Designer -> Appearance ->  ViewCaption -> TextOptions -> HAlignment : Center

12 : GridView添加CheckBox 并支持多选操作.

GridView : Run Designer ->  OptionsSelection -> MultiSelect : True    MultiSelectMode : CheckBoxRowSelect

13 : GridView 添加 序号 列

GridView : Run Designer ->  Event  -> CustomDrawRowIndicator

在事件中添加代码 :

 1 e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
2 if (e.Info.IsRowIndicator)
3 {
4 if (e.RowHandle >= 0)
5 {
6 e.Info.DisplayText = (e.RowHandle + 1).ToString();
7 }
8 else if (e.RowHandle < 0 && e.RowHandle > -1000)
9 {
10 e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite;
11 e.Info.DisplayText = "G" + e.RowHandle.ToString();
12 }
13 }

另外在 Run Desginer ->  IndicatorWidth  设置序号列的宽度 一般30左右就比较适合一些了.

14 : 单元格双击响应

 1  private void gridControl1_DoubleClick(object sender, EventArgs e)
2 {
3 MouseEventArgs arg = e as MouseEventArgs;
4 if (arg == null)
5 return;
6
7 GridHitInfo hitInfo = gridView1.CalcHitInfo(new Point(arg.X, arg.Y));//获取坐标点
8 if (hitInfo.RowHandle >= 0)
9 {
10 DataRow row = gridView1.GetDataRow(hitInfo.RowHandle);
11 _list.Clear();
12 _list.Add(row[0].ToString());
13 gisResoureMonControl1.SetSelectResource(_list);
14 }
15 }

15 : 获取选中行的值

代码:

1  private void gridData_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
2 {
3 _id = GWEntLib.Utilities.Mix.ConvertUtils.ToInt32(gridData.GetRowCellValu(e.FocusedRowHandle, "Id"));
4 _emrFileReadList = EMRTemplateFileReadList.GetEMRTemplateFileReadList(_id);
5 gridVersonData.DataSource = _emrFileReadList;
6
7 }

响应事件:FocusedRowChanged
获取字段值:gridData.GetRowCellValue(e.FocusedRowHandle, "Id")
注意:FocusedRowChanged是Gridview的事件而不是gridControl的事件
gridControl与Gridview的区别:前者是容器,后者为视图

16:将GridView 列表表头固定,无Filter效果

17、DevExpress GridView 获取当前选中行的值。

1  int rowIndex = gridView1.FocusedRowHandle;
2 DataRow dr = gridView1.GetDataRow(rowIndex);
3 MessageBox.Show("课件 \"" + dr.ItemArray[0].ToString() + "\" 下载成功");

18、GridView 去除选中行虚线。

Run Desginer -> Appearance : FocusRectStyle : none;

。。。。。。

DevExpress GridView 整理的更多相关文章

  1. DevExpress GridView 整理(转)

    DevExpress GridView 那些事儿 1:去除 GridView 头上的 "Drag a column header here to group by that column&q ...

  2. DevExpress gridview下拉框的再次研究

    原文:DevExpress gridview下拉框的再次研究 前几天写了一篇关于研究DevExpress gridview下拉框的随笔(DevExpress gridview下拉框repository ...

  3. DevExpress GridView 那些事儿

    1:去除 GridView 头上的 "Drag a column header here to group by that column" -->  点击 Run Desig ...

  4. Devexpress Gridview 自定义汇总CustomSummaryCalculate(加权平均)

    Devexpress Gridview 提供了简单的求和,平均等方法,复杂的汇总方法则需要自定义,使用gridview 的CustomSummaryCalculate 事件,根据官网的文档及各论坛案例 ...

  5. DevExpress GridView属性说明

    转自http://www.cnblogs.com/-ShiL/archive/2012/06/08/ShiL201206081335.html (一)双击展开,收缩字表 1 Private Sub E ...

  6. Devexpress GridView 列中显示图片

    首先将图片添加到ImageList中 添加GridView中Column void gridView1_CustomUnboundColumnData(object sender, DevExpres ...

  7. Devexpress GridView 数据格式化显示

    gridView1.CustomColumnDisplayText += gridView1_CustomColumnDisplayText; void gridView1_CustomColumnD ...

  8. DevExpress GridView对表格的部分说明

    1. int[] selects = this.m_grdView1.GetSelectedRows(); // 获取选中的行,可能是几行 2. this.m_grdView1.GetRowCellV ...

  9. DevExpress GridView中加入CheckBox方法

    添加一列,FieldName为 "check",将ColumnEdit 设置为 复选框 样式.gridview1 editable设置为true 将要绑定的DataTable添加列 ...

随机推荐

  1. HDU - 5917 水题

    题意:n个点m条边,找点集个数,点集满足有任意三个点成环,或者三个点互不相连 题解:暴力复杂度O(n^5/120*O(ok))==O(能过) //#pragma comment(linker, &qu ...

  2. 2243: [SDOI2011]染色 树链剖分+线段树染色

    给定一棵有n个节点的无根树和m个操作,操作有2类: 1.将节点a到节点b路径上所有点都染成颜色c: 2.询问节点a到节点b路径上的颜色段数量(连续相同颜色被认为是同一段), 如“112221”由3段组 ...

  3. vue/webpack的一些小技巧

    都知道我比较懒,今天给大家分享的就是如何让自己省事. 一.vue修改打包后的结构(不知道怎么描述合理,看效果图) /config/index.js 默认的: 修改的:(顺手修改了打包后的文件名) 这样 ...

  4. css样式中position和_position的区别

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA3IAAAEUCAIAAADhh5PYAAAgAElEQVR4nO3dPa/rNoLGcX6dW6UL+B ...

  5. IOS-static cell 与 dynamic cell 混合使用

    static cell 与 dynamic cell 混合使用 关于静态cell与动态cell的混合使用,google一下便会有很多相关文章,这里也是看过一些前辈的经验(已经忘记具体是从哪篇文章得到的 ...

  6. 【Matplotlib】线设置,坐标显示范围

    改变线的颜色和线宽 参考文章: controlling line properties Line API 线有很多属性你可以设置:线宽,线型,抗锯齿等等:具体请参考matplotlib.lines.L ...

  7. 简述 AJAX 及基本步骤

    简述 AJAX:AJAX即“Asynchronous Javascript And XML”(异步 JavaScript 和 XML),是指一种创建交互式网页应用的网页开发技术.通过在后台与服务器进行 ...

  8. 99%的人都理解错了HTTP中GET与POST的区别(转自知乎)

    作者:Larry链接:https://zhuanlan.zhihu.com/p/22536382来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. GET和POST是HTT ...

  9. react native遇到的坑

    1.模拟器报错no bundle url present https://github.com/facebook/react-native/issues/12754 http://www.cnblog ...

  10. node 应用集合

    node+react上传 淘宝的formidable express部署