devexpress 经验笔记
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
2
3
4
5
|
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
public void ButtonInitial() { RepositoryItemButtonEdit rib = new RepositoryItemButtonEdit(); rib.TextEditStyle = TextEditStyles.HideTextEditor; rib.Buttons[ 0 ].Kind = ButtonPredefines.Glyph; rib.ButtonClick += rib_ButtonClick; rib.Buttons[ 0 ].Caption = "详细信息" ; rib.Buttons[ 0 ].Visible = true ; gridView1.Columns[ "DOWNSTATE" ].ColumnEdit = rib; } void rib_ButtonClick(object sender, ButtonPressedEventArgs e) { int rowindex = gridView1.FocusedRowHandle; DataRow row = gridView1.GetDataRow(rowindex); } |
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
2
3
4
5
6
7
8
9
10
11
12
13
|
e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; if (e.Info.IsRowIndicator) { if (e.RowHandle >= 0 ) { e.Info.DisplayText = (e.RowHandle + 1 ).ToString(); } else if (e.RowHandle < 0 && e.RowHandle > - 1000 ) { e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite; e.Info.DisplayText = "G" + e.RowHandle.ToString(); } } |
另外在 Run Desginer -> IndicatorWidth 设置序号列的宽度 一般30左右就比较适合一些了.
14 、单元格双击响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
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); } } |
15 、获取选中行的值
代码:
1
2
3
4
5
6
7
|
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的区别:前者是容器,后者为视图
16、将GridView 列表表头固定,无Filter效果

17、DevExpress GridView 获取当前选中行的值。
1
2
3
|
1 int rowIndex = gridView1.FocusedRowHandle; 2 DataRow dr = gridView1.GetDataRow(rowIndex); 3 MessageBox.Show( "课件 \"" + dr.ItemArray[ 0 ].ToString() + "\" 下载成功" ); |
出处http://www.cnblogs.com/Albin/
devexpress 经验笔记的更多相关文章
- DevExpress使用笔记
DevExpress这套控件用了也有几年的时间了,现在用的版本是14.2.2. 确实是很强大的一套控件,用的好,做出的效果也是相当的好,记录一些平常用到的代码,就当记笔记吧,慢慢完善,其实网上也有大把 ...
- [置顶] 单片机C语言易错知识点经验笔记
今天写这一篇文章并不是因为已经想好了一篇文章才写下来,而是我要将这一篇文章作为一个长期的笔记来写,我会一直更新.在进行单片机开发时,经常都会出现一些很不起眼的问题,这些问题其实都是很基础的c语言知识点 ...
- DevExpress学习笔记之如何获取Repository Item的值
上一章我们看到了如何在TreeList的单元格中动态绑定不同的控件,此类控件被称为In_Place Control.所谓“In_Place”,我的理解为“内置”控件,既然有“内”就相对的会有“外”,其 ...
- Note | 常用指令,工具,教程和经验笔记
目录 图像处理 机器学习和数学 编程环境和工具 写作工具 其他 图像处理 获取图像频域并分解为高低频:https://www.cnblogs.com/RyanXing/p/11630493.html ...
- Xcode编程环境经验笔记(持续汇总)
1.工程路径设置(Search Paths) Header Search Paths:$(SRCROOT)/include Library Search Paths:$(SRCROOT)/lib $( ...
- DevExpress学习笔记1-ProductsDemo.Win
最近在学习ProductsDemo.Win,有一些体会记录下来,大家分享: 在Contacts模块: 在Private Sub UpdateCurrentContact()过程添加一句:InitInd ...
- Flex 经验笔记二
向 Module 传递数据:好像只能传递些像 整型,字符型等简单类型的数据,也能传递像 json 这样的 Object 对象,但如果 Object 对象是从层的,其子级数据,好像也读取不到. func ...
- Flex 经验笔记一
Module页面嵌套子Module页面直接用标签嵌入是不行的,无法显示出来,需要用到 ModuleManager 使用ModuleInfo 的 addEventListener 判断当子Module ...
- Unity3d代码从Android/IOS迁移到WindowsPhone经验笔记
[1搭建坏境] 推荐:Windows 8.1 Enterprise + Visual studio 2013(完整安装) PS: 假设要Visual Studio 2012,先安装VS再安装WP8/W ...
随机推荐
- threadlocal作用
理解:通过thread创建局部变量,每个线程可以获得该变量的副本,再每个线程中操作该副本相互之间不产生影响. 解决:数据库连接 常规一个线程连接一个数据库是没有问题的,但是在高并发的情况下,可能线程一 ...
- bzoj3779: 重组病毒 link-cut-tree
题目传送门 这道题看了做了个神转换.....推荐个博客给各位大爷看看吧神犇传送门 代码敲了半天....题目也读了半天 线段树维护的东西很容易和lct混在一起 调了调能过也是很开心啊 运气比较好吧233 ...
- [POJ1180&POJ3709]Batch Scheduling&K-Anonymous Sequence 斜率优化DP
POJ1180 Batch Scheduling Description There is a sequence of N jobs to be processed on one machine. T ...
- swift中_的用法,忽略默认参数名。
swift中默认参数名除了第一个之外,其他的默认是不忽略的,但是如果在参数的名字前面加上_,就可以忽略这个参数名了,虽然有些麻烦,但是这种定义也挺好,而且不想知道名字或者不想让别人知道名字的或者不用让 ...
- LeetCode 4 :Majority Element
problem:Given an array of size n, find the majority element. The majority element is the element tha ...
- IEEE 802.15介绍
1. 无线通信 无线通信主要是利用无线电(Radio)射频(RF)技术的通信方式,无线网络是采用无线通信技术实现的网络无线网络可为两种: 近距离无线网络和远距离无线网络 近距离无线网络主要可分为如下两 ...
- VS mfc MessageBox() 使用英文显示
转载:http://blog.csdn.net/guoyk1990/article/details/44337249 由于特殊原因我们需要将 MessageBox 或 Dialog 的按钮“确定”.“ ...
- strace 命令是一种强大的工具,它能够显示所有由用户空间程序发出的系统调用。
strace 命令是一种强大的工具,它能够显示所有由用户空间程序发出的系统调用. http://bbs.51cto.com/thread-1106891-1.html
- js判断处理undefined类型的数据
code: resFlag = response.result.data.result; /查询客户为白名单用户时,将"*该企业已被列入黑名单"标记清除 if(typeof res ...
- 解决xshell 、SecureCRT中文乱码
一.解决xshell 中文乱码 在xshell命令行里面 输入: locale输出: LANG=zh_CN.UTF-8LC_CTYPE="zh_CN.UTF-8"LC_NUMERI ...