include a image in devexpress datagrid
- Add an ImageCollection to yout form and add some icons 16x16 to it.
- Add a column to the Grid for the icons.
- Set the column's fieldName to image (whatever you like).
- Set the column's UnboundType to Object.
- Add a repositoryItemPictureEdit to the column's columnEdit.
All the above can be done in the designer. Then do the following
privatevoid gridView1_CustomUnboundColumnData(object sender,DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e){if(e.Column== colImage1 && e.IsGetData){string someValueFromDatabase =(string)gridView1.GetRowCellValue(e.RowHandle, colOne);if(someValueFromDatabase =="a"){//Set an icon with index 0
e.Value= imageCollection1.Images(0);}else{//Set an icon with index 1
e.Value= imageCollection1.Images(1);}}}
The key here is handling the CustomUnboundColumnData and the repositoryItemPictureEdit.
***
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors.Repository;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private DataTable CreateTable(int RowCount)
{
Image[] images = new Image[] { WindowsApplication1.Properties.Resources.about, WindowsApplication1.Properties.Resources.add, WindowsApplication1.Properties.Resources.apple, WindowsApplication1.Properties.Resources.arrow_down, WindowsApplication1.Properties.Resources.arrow_left};
DataTable tbl = new DataTable();
tbl.Columns.Add("Name", typeof(string));
tbl.Columns.Add("ID", typeof(int));
tbl.Columns.Add("Number", typeof(int));
tbl.Columns.Add("Date", typeof(DateTime));
tbl.Columns.Add("Image", typeof(Image));
for (int i = 0; i < RowCount; i++)
tbl.Rows.Add(new object[] { String.Format("Name{0}", i), i, 3 - i, DateTime.Now.AddDays(i), images[i % images.Length] });
return tbl;
}
public Form1()
{
InitializeComponent();
gridControl1.DataSource = CreateTable(20);
gridView1.Columns["Image"].ColumnEdit = new RepositoryItemPictureEdit();
}
}
}
include a image in devexpress datagrid的更多相关文章
- Xamarin devexpress datagrid 样式
DevExpress的提供光与暗的内置,可以应用到主题GridControl改变其外观. 主题 iOS版 Android版 光(默认适用于iOS) 黑暗(默认为Android) 应用预定义的主题 ...
- Devexpress datagrid动态添加显示指定列的gridView
代码如下: public class DXGridControlHelper { /// <summary> /// 获取显示指定列的GridView /// </summary&g ...
- devexpress datagrid 与imageEdit以及如何存图片到数据库 z
http://blog.csdn.net/haoyujie/article/details/41277703 首先建立了一个数据库的表,这个表中,有一个字段是image类型(SQL Server数据库 ...
- [DevExpress] - 在 DataGrid 中添加多选复选框的方法
设置方法 在 GridView 中设置 OptionSelection 属性如下: 效果 参考资料 https://stackoverflow.com/a/9078848http://blog.csd ...
- Devexpress VCL Build v2014 vol 15.2.3 发布
2016年第一个版本,继续修补. New Major Features in 15.2 What's New in VCL Products 15.2 Breaking Changes To lear ...
- csharp: Data binding in WPF DataGrid control
<Window x:Class="WpfProjectDemo.MainWindow" xmlns="http://schemas.microsoft.com/wi ...
- easyui datagrid 增删改查示例
查询JSP页面 <!doctype html> <%@include file="/internet/common.jsp"%> <!-- 新样式右侧 ...
- Easy-UI 动态添加DataGrid的Toolbar按钮
在前人的基础上进行的修改,不知道他是从哪里引用来的,所以没有粘贴引用地址. 原代码不支持1.3.6. 修改功能: 1.如果之前没有添加过工具,用这个方法不能添加(已修复): 2.估计是不支持1.3.6 ...
- VS2010 MFC DataGrid绑定实例
VS2010环境下MFC使用DataGrid绑定数据源 参考:http://blog.csdn.net/fddqfddq/article/details/7874706 详细介绍如何在MFC中使用Da ...
随机推荐
- html-----013----实体字符/HTML URL 编码
<!DOCTYPE> 声明 版本 年份 HTML 1991 HTML+ 1993 HTML 2.0 1995 HTML 3.2 1997 HTML 4.01 1999 XHTML 1.0 ...
- EOF是什么?
转自http://www.ruanyifeng.com/blog/2011/11/eof.html 学习C语言的时候,遇到的一个问题就是EOF. 它是end of file的缩写,表示"文字 ...
- Headfirst设计模式的C++实现——命令模式(Command)
先看如果不用命令模式的实现: light.h #ifndef _LIGHT_H_ #define _LIGHT_H #include <iostream> class LIGHT { pu ...
- XSS漏洞(跨站脚本)
不要轻信用户提交上来的数据alert消息太难看,因此开发一个aspx页面用来统一展示消息ShowMessage.ashx //主页将判断重定向到另一个页面 if (TextBox1.Text != & ...
- JS当前日期相加相减
function DateAddORSub(interval,type,number) { /* * 功能:实现Script的Date加减功能. * 参数:interval,字符串表达式,表示要添加的 ...
- shell中的双引号,单引号,反引号
在shell中引号分为三种:单引号,双引号和反引号. 单引号 ‘ 由单引号括起来的字符都作为普通字符出现.特殊字符用单引号括起来以后,也会失去原有意义,而只作为普通字符解释.单引号用于保持引号内所有字 ...
- win7的IE11降到IE8
我为什么要降低IE版本呢?...... 下载了抓包工具HttpWatch,下载地址http://pan.baidu.com/s/1kVhPMmj 版本如下: 用IE11打开抓包时流内没有内容,可能跟 ...
- PHP程序缓存之文件缓存处理方式
PHP程序缓存之文件缓存处理方式在开发程序过程中,缓存的设置大大提升程序效率,减小数据库负载.基本配置缓存和常规配置缓存 基本配置缓存在项目开发中类似这样子的格式: 文件:config.php $CF ...
- Poco之ftp获取文件列表以及下载文件
#include <iostream>#include <string>#include <vector>#include <algorithm>#in ...
- STM32之SD卡
目录 一.SD卡概述 1.定义 2.容量等级 3.SD卡框图 4.SD卡与TF卡的区别 二. SD卡内部结构 1. SD卡内部结构简图 2. 存储阵列结构图 3.Buffer 4.“存储阵列Block ...