DevExpress gridView 小结(一)
一:第一列显示行号 CustomDrawRowIndicator
this.gridViewDevice.IndicatorWidth = 40;
this.gridViewDevice.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridViewDevice_CustomDrawRowIndicator);
void gridViewDevice_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
{
e.Info.DisplayText = Convert.ToString(Convert.ToInt32(e.RowHandle.ToString()) + 1);
}}
二:不同行显示不同背景颜色 RowStyle
private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
if (e.RowHandle >= 0)
{
String category = view.GetRowCellDisplayText(e.RowHandle, view.Columns["字段名称"]);
if (category == "显示颜色的条件")
{
e.Appearance.BackColor = Color.LightGreen;
}
}}
三:不同单元格显示不同背景色 RowCellStyle
private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
GridView View = sender as GridView;
if (e.Column.FieldName == "绑定的字段")
{
string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["字段名称"]);
if (category == "满足字段的条件")
{
e.Appearance.BackColor = Color.LightCoral;
e.Appearance.BackColor2 = Color.LightPink;
}}}
四:添加列图标 CustomUnboundColumnData
添加图标列,FieldName设为Image
Hashtable Images = new Hashtable(); //图标集合
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
if (e.Column.FieldName == "Image" && e.IsGetData)
{
String 条件 = (String)((DataRowView)e.Row)["查找字段"].ToString();
String fileName = "1.png";
switch (条件)
{
case "1":
fileName = "1.png";
break;
case "2":
fileName = "2.png";
break;
}
if (!Images.ContainsKey(fileName))
{
Image img = null;
try
{
String filePath = System.IO.Path.Combine(Application.StartupPath.ToString(), @"Resource\Icon", fileName);
img = Image.FromFile(filePath);
}
catch{}
Images.Add(fileName, img);
}
e.Value = Images[fileName];
}
}
DevExpress gridView 小结(一)的更多相关文章
- DevExpress gridview下拉框的再次研究
原文:DevExpress gridview下拉框的再次研究 前几天写了一篇关于研究DevExpress gridview下拉框的随笔(DevExpress gridview下拉框repository ...
- DevExpress GridView 整理(转)
DevExpress GridView 那些事儿 1:去除 GridView 头上的 "Drag a column header here to group by that column&q ...
- DevExpress GridView 那些事儿
1:去除 GridView 头上的 "Drag a column header here to group by that column" --> 点击 Run Desig ...
- Devexpress Gridview 自定义汇总CustomSummaryCalculate(加权平均)
Devexpress Gridview 提供了简单的求和,平均等方法,复杂的汇总方法则需要自定义,使用gridview 的CustomSummaryCalculate 事件,根据官网的文档及各论坛案例 ...
- DevExpress GridView 整理
1:去除 GridView 头上的 "Drag a column header here to group by that column" --> 点击 Run Desig ...
- Devexpress GridView 列中显示图片
首先将图片添加到ImageList中 添加GridView中Column void gridView1_CustomUnboundColumnData(object sender, DevExpres ...
- Devexpress GridView 数据格式化显示
gridView1.CustomColumnDisplayText += gridView1_CustomColumnDisplayText; void gridView1_CustomColumnD ...
- DevExpress GridView属性说明
转自http://www.cnblogs.com/-ShiL/archive/2012/06/08/ShiL201206081335.html (一)双击展开,收缩字表 1 Private Sub E ...
- DevExpress GridView中加入CheckBox方法
添加一列,FieldName为 "check",将ColumnEdit 设置为 复选框 样式.gridview1 editable设置为true 将要绑定的DataTable添加列 ...
随机推荐
- 构建千万级web访问架构
. HTML静态化 其实大家都知道,效率最高.消耗最小的就是纯静态化的html页面,所以我们尽可能使我们的网站上的页面采用静态页面来实现,这个最简单的方法其实也是最有效的方法.但是对于大量内容并且频繁 ...
- MII接口全家福
转载:http://blog.chinaunix.net/uid-24148050-id-131084.html 简介: MII是英文Medium Independent Interface的缩 ...
- c++暂停
#include<cstdlib> 加入这个 然后 system("pause");
- visual studio 因为文件过期重新编译项目
最近visual studio总是莫名其妙的重新编译某个工程, 导致大量项目rebuild . 蛋都碎了... 查了好久, 这种无厘头的问题最烦了 参考这篇文章, http://blogs.msdn ...
- [转] 详解http和https的作用与区别
PS: https就是http和TCP之间有一层SSL层,这一层的实际作用是防止钓鱼和加密.防止钓鱼通过网站的证书,网站必须有CA证书,证书类似于一个解密的签名.另外是加密,加密需要一个密钥交换算法, ...
- ORM之PetaPoco错误--VS中NUGet程序包管理安装PetaPoco
一般在Vs中使用PetaPoco的时候都是使用NuGet程序包管理来安装PetaPoco的,如果你在安装PetaPoco前设置了ConnectionString,那么PetaPoco中的T4模板会自动 ...
- LeetCode 142
Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cyc ...
- LeetCode 283
Move Zeros Given an array nums, write a function to move all 0's to the end of it while maintaining ...
- LeetCode 226
Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 /** ...
- hdu 1195 广度搜索
这题我们可以用优先队列,每次弹出队列中操作次数最少的一个,那么当找到匹配数时,该值一定是最优的.需要注意的时,加个vi[]数组,判读当前数是否已经存在于队列中.我做的很烦啊~~~ #include&l ...