一:第一列显示行号  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 小结(一)的更多相关文章

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

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

  2. DevExpress GridView 整理(转)

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

  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 整理

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

  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属性说明

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

  9. DevExpress GridView中加入CheckBox方法

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

随机推荐

  1. LVS 之 DR model arp_announce arp_ignore转

    DR模式的收发流程: 1)客户端发起请求到调度器的vip.2)调度器根据调度算法在各个服务器中动态选择一台服务器,但它不修改ip报文,而是将数据帧的MAC地址改为选出服务器的MAC地址.再将修改名的数 ...

  2. Why Python is Slow

    Why Python is Slow: Looking Under the Hood https://jakevdp.github.io/blog/2014/05/09/why-python-is-s ...

  3. Android进阶笔记08:Android 中Activity、Window和View之间的关系

    1. Android 中Activity.Window和View之间的关系(比喻): Activity像一个工匠(控制单元),Window像窗户(承载模型),View像窗花(显示视图) LayoutI ...

  4. js页面刷新的几种方法

    Javascript刷新页面的几种方法: 1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(locat ...

  5. SSIS 学习(9):包部署常见问题汇总【转】

    Integration Services 包在部署过程中,经常会出现这样那样的问题,让人摸不着头脑,很是烦人.下面我就将我在部署过程中,遇到的一些问题整理出来,以供大家参考. (一)SSIS包在SQL ...

  6. hadoop学习记录(二)HDFS java api

    FSDateinputStream 对象 FileSystem对象中的open()方法返回的是FSDateInputStream对象,改类继承了java.io.DateInoutStream接口.支持 ...

  7. Linux(CentOS6.5)系统安装Nginx

    Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口 ...

  8. jquery基础教程读书总结

    最近静下心来看书才深刻的体会到:看书真的很重要,只有看书才能让你有心思静下心来思考. 重温<jquery基础教程> 一.事件 主要掌握常见的事件以及理解jquery的事件处理机制. 需要注 ...

  9. trigger,triggerhandler模拟事件

    常用模拟 有时候,需要通过模拟用户操作,来达到单击的效果.例如在用户进入页面后,就触发click事件,而不需要用户去主动单击. 在JQuery中,可以使用trigger()方法完成模拟操作.例如可以使 ...

  10. Git CMD - mv: Move or rename a file, a directory, or a symlink

    命令格式 git mv [-v] [-f] [-n] [-k] <source> <destination> git mv [-v] [-f] [-n] [-k] <so ...