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. .NET面试题系列[12] - C# 3.0 LINQ的准备工作

    "为了使LINQ能够正常工作,代码必须简化到它要求的程度." - Jon Skeet 为了提高园子中诸位兄弟的英语水平,我将重要的术语后面配备了对应的英文. .NET面试题系列目录 ...

  2. Java NIO5:选择器1---理论篇

    选择器 最后,我们探索一下选择器.由于选择器内容比较多,所以本篇先偏理论地讲一下,后一篇讲代码,文章也没有什么概括.总结的,写到哪儿算哪儿了,只求能将选择器写明白,并且将一些相对重要的内容加粗标红. ...

  3. C++11 并发指南七(C++11 内存模型一:介绍)

    第六章主要介绍了 C++11 中的原子类型及其相关的API,原子类型的大多数 API 都需要程序员提供一个 std::memory_order(可译为内存序,访存顺序) 的枚举类型值作为参数,比如:a ...

  4. 探索c#之跳跃表(SkipList)

    阅读目录: 基本介绍 算法思想 演化步骤 实现细节 总结 基本介绍 SkipList是William Pugh在1990年提出的,它是一种可替代平衡树的数据结构. SkipList在实现上相对比较简单 ...

  5. [ASP.NET MVC 小牛之路]10 - Controller 和 Action (2)

    继上一篇文章之后,本文将介绍 Controller 和 Action 的一些较高级特性,包括 Controller Factory.Action Invoker 和异步 Controller 等内容. ...

  6. Azure Table storage 基本用法 -- Azure Storage 之 Table

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table,其中的 Table 就是本文的主角 Azure Tabl ...

  7. 微信为什么发布 Mac 版?

    因为 Mac 就是好啊就是好啊,就是好…… 打完收工,谢谢,鼓掌 piapiapia……晚安! 这么写在京城行走会不会挨板砖呢?头像已经印到书上满世界的发出去了,虽然考虑到行走江湖求一个稳字,我还特意 ...

  8. Stored Procedure 里的 WITH RECOMPILE 到底是干麻的?

    在 SQL Server 创建或修改「存储过程(stored procedure)」时,可加上 WITH RECOMPILE 选项,但多数文档或书籍都写得语焉不详,或只解释为「每次执行此存储过程时,都 ...

  9. Redis 发布订阅用法

    一.发布订阅模型发布订阅其作用是为了减少依赖关系,通常也叫观察者模式.主要是把耦合点单独抽离出来作为第三方,隔离易变化的发送方和接收方. 发送方:只负责向第三方发送消息.(杂志社把读者杂志交给邮局)接 ...

  10. Text文档编码识别方法

    Text文档编码识别方法 在做文档读取的时候,时常碰到编码格式不正确的问题,而要怎么样正确识别文档的编码格式,成了很多程序员的一块心病,今天我就要试着治好这块心病,这段代码的浓缩来自上千万文档的数据分 ...