Devexpress GridView 数据格式化显示
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 数据格式化显示的更多相关文章
- GridView数据格式化
一.动态生成列的格式化 此种GridView中的列是动态生成的,格式化可以通过RowDataBound事件进行.如下边代码,对第十列的值进行格式化. protected void gvUserList ...
- Devexpress GridView 列中显示图片
首先将图片添加到ImageList中 添加GridView中Column void gridView1_CustomUnboundColumnData(object sender, DevExpres ...
- C# DevExpress 的gridControl或gridView数据导出失败解决方法
来自:http://blog.csdn.net/lybwwp/article/details/8049464 谢谢 在使用DevExpress 的GridPanel控件的时候出现了一个莫名其妙的现象, ...
- EasyUI datagrid 格式化显示数据
http://blog.163.com/ppy2790@126/blog/static/103242241201512502532379/ 设置formatter属性,是一个函数,格式化函数有3个参数 ...
- 扩展:gridview 空数据时显示表头
2015年7月14日16:50:06 Gridview 默认展示数据时,若数据为空,则表格不显示,显示不美观. 针对此问题进行扩展: using System.Web.UI.WebControls; ...
- DevExpress GridView 整理(转)
DevExpress GridView 那些事儿 1:去除 GridView 头上的 "Drag a column header here to group by that column&q ...
- DevExpress GridView自动滚动
引言 最新有一个winform项目使用的是DevExpress的控件,所以最近都在摸索使用这套控件,实在是佩服整套控件的强大,同时代码写起来也简洁.客户有一个需求,希望报表结果能在外接的大屏幕上定时滚 ...
- DevExpress GridView 那些事儿
1:去除 GridView 头上的 "Drag a column header here to group by that column" --> 点击 Run Desig ...
- DevExpress GridView 整理
1:去除 GridView 头上的 "Drag a column header here to group by that column" --> 点击 Run Desig ...
随机推荐
- node(async原理)
node中的async是用来实现同步操作的,提供包括map.Series等方法,本文不做赘述. 由于项目需要在浏览器端用了async.js,因此仔细看了下它的代码.原来,一直以为node是在服务端调用 ...
- (DNS被劫持所导致的)QQ音乐与视频网页打开很慢的解决方法
这周开始发现一个很让人抓狂的现象,QQ音乐网页(http://y.qq.com)与QQ视频(http://v.qq.com/)网页打开超慢,甚至是无法打开,严重影响了业余的音乐视频生活. 以QQ视频为 ...
- Hadoop学习笔记—11.MapReduce中的排序和分组
一.写在之前的 1.1 回顾Map阶段四大步骤 首先,我们回顾一下在MapReduce中,排序和分组在哪里被执行: 从上图中可以清楚地看出,在Step1.4也就是第四步中,需要对不同分区中的数据进行排 ...
- SEO:让搜索引擎对你的网站更有亲和力(译)
人可以通过查看网站信息了解网站的内容,但是搜索引擎只对标签感兴趣,对内容的识别能力是很低的,如何让蜘蛛通过标签认识你的文章内容呢~ 原文网址:http://schema.org/docs/gs.htm ...
- clojure基础入门(一)
最近在看storm的源码,就学习分享下clojure语法. 阅读目录: 概述 变量 运算符 流程控制 总结 概述 clojure是一种运行在JVM上的Lisp方言,属于函数式编程范式,它和java可以 ...
- Docker:镜像操作和容器操作
镜像操作 列出镜像: $ sudo docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE hello-world latest 0a6b ...
- 使用ViewPager+Fragment实现选项卡切换效果
实现效果 本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动屏幕会切换Fragment并实现选项卡下方下边框条跟随移动效果. 本程序用androi ...
- Python----reduce原来是这样用的
官方解释: Apply function of two arguments cumulatively to the items of iterable, from left to right, so ...
- .NET 基础 一步步 一幕幕 [.NET 简介]
.NET 简介 .NET是 Microsoft XML Web services 平台.是微软用来实现XML,Web Services,SOA(面向服务的体系结构service-oriented ar ...
- java spring 邮件发送
开发中经常会遇到发送邮件进行用户验证,或者其它推送信息的情况,本文基于spring,完成邮件的发送,主要支持普通文本邮件的发送,html文本邮件的发送,带附件的邮件发送,没有实现群发.多个附件发送等需 ...