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添加列 ...
随机推荐
- Jquery 表格固定表头
网上找了好多现成的.结果没一个能成.只得自己动手. (function($){ $.fn.fixHeader = { init : function(obj){ var p = obj.parent( ...
- 基础笔记(二)HTTP协议
GET与POST的区别 1.GET提交的数据会放在URL之后,以?分割URL和传输数据,参数之间用&连接:POST是把提交的数据放在HTTP的body中. 2.GET提交的数据大小有限制(协议 ...
- NopCommerce Html扩展方法Html.Widget
在Nop中有一个Html扩展的类叫HtmlExtensions,主要源码: public static class HtmlExtensions { #region Admin area extens ...
- MySQL_前缀索引_建立
-- 查看出现频率select count(*) as cnt,cityfrom sakila.city_demo group by city order by cnt desc limit 10; ...
- PHP如何抓取https内容?记录一下。
PHP里做一般的获取内容时,用自带的file_get_contents()函数基本就足够了.当然,这个函数只能抓一些简单的数据,如果是遇到需要登录的页面,就不行了,而且效率及稳定性也不是很强.所以要是 ...
- memcahced 更新
memcahc特性: 在 Memcached中可以保存的item数据量是没有限制的,只要内存足够 . Memcached单进程在32位系统中最大使用内存为2G,若在64位系统则没有限制,这是由于32位 ...
- Java设计模式12:常用设计模式之外观模式(结构型模式)
1. Java之外观模式(Facade Pattern) (1)概述: 现代的软件系统都是比较复杂的,设计师处理复杂系统的一个常见方法便是将其"分而治之",把一个系统划 ...
- tomcat初识
1.新工作使用tomcat,顺便就把tomcat搜了搜,看了下基础 官网:http://tomcat.apache.org/ 打开官网会发现很多版本6,7,8,9,这些版本都有什么区别呢?tomcat ...
- Redis中文显示为Unicode编码的解决办法
通过Xshell远程连接Linux中的Redis数据库.... 存入Reids中的value有中文. Xshell得到之后中文并不显示为乱码,显示的是中文对应的Unicode编码: 在Xshell中字 ...
- 基于ArcEngine与C#的鹰眼地图实现
鹰眼图是对全局地图的一种概略表达,具有与全局地图的空间参考和空间范围.为了更好起到空间提示和导航作用,有些还具备全局地图中重要地理要素,如主要河流.道路等的概略表达.通过两个axMapControl控 ...