一:Clone返回新的 DataTable

Clone返回新的 DataTable,与当前的 DataTable 具有相同的架构;Copy:返回新的 DataTable,它具有与该 DataTable 相同的结构(表架构和约束)和数据

DataRow[] _dr = DT.Select("CLSSBH='"+ Filter_Str +"'"); 
DataTable dt = DT.Clone() ; 
DataRow dr ; 
for( int j = 0 ;j < _dr.Length ;j ++ ) 

dr = dt.NewRow() ; 
dr = _dr[j] ; 
dt.ImportRow( dr ) ; 

  
我一般使用DataTable.Rows.Add(row.ItemArray);

二:选中某一行

GridView.FocusedRowHandle =i;
GridView.SelectRow(i);

三:遍历GridView

for (int i = 0; i < gridView1.RowCount; i++)
{
       for (int j = 0; j < gridView1.Columns.Count; j++)
       {
             object val = gridView1.GetRowCellValue(i, gridView1.Columns[j]);
       }
}

四:单元格双击响应

需要先将gridview1.OptionsBehavior.Editable设为false,然后响应gridControl1_DoubleClick事件。

private void gridControl1_DoubleClick(object sender, EventArgs e)
        {
            MouseEventArgs arg = e as MouseEventArgs;
            if (arg == null)
                return;

GridHitInfo hitInfo = gridView1.CalcHitInfo(new Point(arg.X, arg.Y));//获取坐标点
            if (hitInfo.RowHandle >= 0)
            {
                DataRow row = gridView1.GetDataRow(hitInfo.RowHandle);
                _list.Clear();
                _list.Add(row[0].ToString());
                gisResoureMonControl1.SetSelectResource(_list);
            }           
        }

五:GridView隐藏行

需要响应CustomRowFilter事件,用来设置过滤条件;

需要根据原始数据源结合起来,才能方便地隐藏或者显示行;

/// <summary>
        /// 根据条件查询并在表格中显示结果
        /// </summary>
        /// <param name="strCondition"></param>
        private void QueryTable(string strCondition)
        {
            DataTable table = gridControl1.DataSource as DataTable;
            if (table == null)
                return;

_indexlist.Clear();

for (int i = 0; i < table.Rows.Count; i++)
            {
                for (int j = 0; j < table.Columns.Count; j++)
                {
                    if(table.Rows[i][j].ToString().Contains(strCondition))
                    {
                        _indexlist.Add(i);
                        gridView1.RefreshData();
                        break;
                    }
                }
            }

if (_indexlist.Count==0)
                HideGridView();                      
        }

/// <summary>
        /// gridView的行隐藏或显示的过滤条件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomRowFilter(object sender, RowFilterEventArgs e)
        {
            if (_indexlist.Count == 0)
                return;

if(_indexlist.Contains(-2))
                e.Visible = true;   //全显示
            else if (_indexlist.Contains(-3))
                e.Visible = false;   //全隐藏
            else if(_indexlist.Contains(e.ListSourceRow))
                e.Visible = true;
            else
                e.Visible = false;

e.Handled = true;
        }

Devexpress GridView部分常用操作总结 z的更多相关文章

  1. Mac OS X常用操作入门指南

    前两天入手一个Macbook air,在装软件过程中摸索了一些基本操作,现就常用操作进行总结, 1关于触控板: 按下(不区分左右)            =鼠标左键 control+按下        ...

  2. linux常用操作指令

    Linux常用操作指令: 常用指令 ls        显示文件或目录 -l           列出文件详细信息l(list) -a          列出当前目录下所有文件及目录,包括隐藏的a(a ...

  3. DevExpress GridView 整理(转)

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

  4. DevExpress GridView 那些事儿

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

  5. Java8获取当前时间、新的时间日期类如Java8的LocalDate与Date相互转换、ZonedDateTime等常用操作包含多个使用示例、Java8时区ZoneId的使用方法、Java8时间字符串解析成类

     下面将依次介绍 Date转Java8时间类操作 ,Java8时间类LocalDate常用操作(如获得当前日期,两个日期相差多少天,下个星期的日期,下个月第一天等) 解析不同时间字符串成对应的Java ...

  6. linux 常用操作以及概念

    一.常用操作以及概念 查看LINUX发行版的名称及其版本号的命令: lsb_release -a cat /etc/redhat-release(针对redhat,Fedora) 0.rpm包路径:/ ...

  7. DevExpress GridView 整理

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

  8. [PY3]——内置数据结构(1)——列表及其常用操作

    列表及其常用操作_xmind图         about列表 列表是一个序列,用于顺序存储数据 列表分为两种:ArrayList(用数组实现).LinkedList(用链表实现) 定义与初始化 #l ...

  9. nodepad++ 快捷键加常用操作

    常用快捷键 新建文件 Ctrl+N 打开文件 Ctrl+O 保存文件 Ctrl+S 另存为 Ctrl+Alt+S 全部保存 Ctrl+Shift+S 关闭当前文件 Ctrl+W 打印文件 Ctrl+P ...

随机推荐

  1. swift-06-字符串,字符以及元组类型

    1.字符串和字符类型 //在swift中,字符串使用一对双引号括起来 var str = "hello M.SD-DJ" print(str) //字符也要用双引号括起来,用cha ...

  2. html表单 第四节

    实例: <html> <head> <title>表单实例</title> </head> <body> <center& ...

  3. java web环境配置类型问题

    一, cmd查看jdk版本 java -version cmd查看jdk安装路径 java -verbose 二, 如果出现了上述的错误按照如下的3个步骤解决:1.首先关闭MyEclipse工作空间. ...

  4. 24种设计模式--策略模式【Strategy Pattern】

    刘备要到江东娶老婆了,走之前诸葛亮给赵云(伴郎)三个锦囊妙计,说是按天机拆开解决棘手问题,嘿,还别说,真是解决了大问题,搞到最后是周瑜赔了夫人有折兵呀,那咱们先看看这个场景是什么样子的. 先说这个场景 ...

  5. spark-shell - 三个引号,让脚本阅读更开心

    spark-shell中可以直接编写SQL语句从数据源中加载数据. 可以利用scala语言中的多行字符串(三个引号)让SQL语句结构清晰更易于阅读. 示例: sqlContext.sql(" ...

  6. ubuntu zendDebugger.so 加载不上的问题

    参考文章   http://blog.sina.com.cn/s/blog_6612d5810101dapf.html 装zenDdebugger是为了在eclipse中调试用!!!!!!!结果搞了半 ...

  7. leetcode problem 11 Container With Most Water

    Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...

  8. vim 配置文件 ,高亮+自动缩进+行号+折叠+优化

    vim 配置文件 ,高亮+自动缩进+行号+折叠+优化 将一下代码copy到 用户目录下 新建文件为  .vimrc保存即可生效: 如果想所有用户生效 请修改 /etc/vimrc (建议先cp一份)& ...

  9. placeholder属性兼容js支持

    $(function(){ //判断浏览器是否支持placeholder属性 supportPlaceholder='placeholder'in document.createElement('in ...

  10. php中浮点数计算问题

    如果用php的+-*/计算浮点数的时候,可能会遇到一些计算结果错误的问题,比如echo intval( 0.58*100 );会打印57,而不是58,这个其实是计算机底层二进制无法精确表示浮点数的一个 ...