gridView1.CustomColumnDisplayText += gridView1_CustomColumnDisplayText;
void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
if (e.Column.FieldName == "State")
{
switch (e.DisplayText)
{
case "":
e.DisplayText = "有效";
break;
case "":
e.DisplayText = "无效"; break;
}
}
}
    void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
var currentView = sender as GridView;
if (currentView != null && e.RowHandle == currentView.FocusedRowHandle) return;
Rectangle r = e.Bounds;
if (e.Column.FieldName == "F_State")
{
if (e.CellValue.ToString().Equals("False"))
{
e.Appearance.ForeColor=Color.Red;
e.Appearance.DrawString(e.Cache,e.DisplayText,r);
e.Handled = true;
}
}
} 或者以下面的这种形式也可以的、
还有一个就是改变行的颜色
在对GridControl绑定好数据后:
No.1:右键GridControl选择Run Designer;
No.2:Appearance下Style Conditions点击Add,需要注意的是每一个变色条件都得Add一个变色方案;
No.3:在Properties中需要用到的属性依次往下详解为:
a)Appearance下BackColor=255.255.128,BackColor2=255.255.128,此项指定符合特定条件时单元格/行背景颜色,如果两项设置颜色不同时则为渐变效果; 要是每次都这样设置也太不方便了。。所以我又封装了一个方法
        public void SetColumnFormatCell(object value1, object value2,Color backColor1,Color backColor2,GridColumn gridColumn,FormatConditionEnum formatType,GridView gridView)
{
var styleFormatCondition1 = new StyleFormatCondition();
styleFormatCondition1.Appearance.BackColor = backColor1;
styleFormatCondition1.Appearance.BackColor2 =backColor2;
styleFormatCondition1.Appearance.Options.UseBackColor = true;
styleFormatCondition1.Column = gridColumn;
styleFormatCondition1.Condition = formatType;
styleFormatCondition1.Expression = "true";
styleFormatCondition1.Value1 = value1;
styleFormatCondition1.Value2 = value2;
gridView.FormatConditions.Add(styleFormatCondition1);
}
调用:
  var dev=new DataGridControlHelper();
dev.SetColumnFormatCell("无效","无效",Color.Red,Color.Red,gridColumn03,FormatConditionEnum.Equal,gridView1);

 虽然效果是出来了。但是我觉得效率很差。
要是有那位网友有更好的方案。请分享一下。谢谢

Devexpress GridView 数据格式化显示的更多相关文章

  1. GridView数据格式化

    一.动态生成列的格式化 此种GridView中的列是动态生成的,格式化可以通过RowDataBound事件进行.如下边代码,对第十列的值进行格式化. protected void gvUserList ...

  2. Devexpress GridView 列中显示图片

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

  3. C# DevExpress 的gridControl或gridView数据导出失败解决方法

    来自:http://blog.csdn.net/lybwwp/article/details/8049464 谢谢 在使用DevExpress 的GridPanel控件的时候出现了一个莫名其妙的现象, ...

  4. EasyUI datagrid 格式化显示数据

    http://blog.163.com/ppy2790@126/blog/static/103242241201512502532379/ 设置formatter属性,是一个函数,格式化函数有3个参数 ...

  5. 扩展:gridview 空数据时显示表头

    2015年7月14日16:50:06  Gridview 默认展示数据时,若数据为空,则表格不显示,显示不美观. 针对此问题进行扩展: using System.Web.UI.WebControls; ...

  6. DevExpress GridView 整理(转)

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

  7. DevExpress GridView自动滚动

    引言 最新有一个winform项目使用的是DevExpress的控件,所以最近都在摸索使用这套控件,实在是佩服整套控件的强大,同时代码写起来也简洁.客户有一个需求,希望报表结果能在外接的大屏幕上定时滚 ...

  8. DevExpress GridView 那些事儿

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

  9. DevExpress GridView 整理

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

随机推荐

  1. 【腾讯Bugly干货分享】微信小程序开发思考总结——腾讯“信用卡还款”项目实践

    本文来自于腾讯bugly开发者社区,未经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/58212d0fa7a7574c4f4cc3c5 作者:peggy 小程序概述 1 ...

  2. jQuery 2.0.3 源码分析 Deferred(最细的实现剖析,带图)

    Deferred的概念请看第一篇 http://www.cnblogs.com/aaronjs/p/3348569.html ******************构建Deferred对象时候的流程图* ...

  3. 剑指Offer面试题:15.反转链表

    一.题目:反转链表 题目:定义一个函数,输入一个链表的头结点,反转该链表并输出反转后链表的头结点. 链表结点定义如下,这里使用的是C#描述: public class Node { public in ...

  4. nodejs事件轮询详述

    目录 概述 nodejs特点 事件轮询 关于异步方法 概述 关于nodejs的介绍网上资料非常多,最近由于在整理一些函数式编程的资料时,多次遇到nodejs有关的内容.所以就打算专门写一篇文章总结一下 ...

  5. SQL Server 使用全文索引进行页面搜索

    标签:SQL SERVER/MSSQL SERVER/数据库/DBA/全文索引 概述 全文引擎使用全文索引中的信息来编译可快速搜索表中的特定词或词组的全文查询.全文索引将有关重要的词及其位置的信息存储 ...

  6. 完全使用一组 DSL 来操作 Grid 控件

    最近尝试了一下将 XtraGrid 的初始化工作封装成内部 DSL,例如一个普通的基础数据的增删改查操作的代码会像下面这样: public partial class UserForm : XtraF ...

  7. C#设计模式之命令

    IronMan之命令 在本篇中还是围绕着“IronMan”来讲,在上一篇“外观”中我们说到过“控制中心”.它是负责IronMan的核心,所有能想象到的功能都跟它有关系,就在使用它的时候,发现了一些问题 ...

  8. Ubuntu上安装Robomongo及添加到启动器

    到目前为止,Robomongo仍是MongoDB最好的客户端管理工具,如需在Ubuntu上安装Robomongo,可直接从官网下载.tar.gz压缩包进行解压,然后直接运行bin目录下的robomon ...

  9. 移动APP服务端设计开发注意要点

    2014年,移动APP的热度丝毫没有减退,怎么为您的移动端app设计良好的服务器端接口(API)呢? 下面谈谈我个人的一些想法. 2014年,移动APP的热度丝毫没有减退,并没有像桌面软件被WEB网站 ...

  10. SSIS Destination 组件使用Fast-Load mode出错

    查看一个Package的历史Message 数据,发现 DataFlow Task 经常出错,错误信息的Description是: Description: "While reading c ...