• 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的更多相关文章

  1. Xamarin devexpress datagrid 样式

    DevExpress的提供光与暗的内置,可以应用到主题GridControl改变其外观.   主题 iOS版 Android版 光(默认适用于iOS) 黑暗(默认为Android) 应用预定义的主题 ...

  2. Devexpress datagrid动态添加显示指定列的gridView

    代码如下: public class DXGridControlHelper { /// <summary> /// 获取显示指定列的GridView /// </summary&g ...

  3. devexpress datagrid 与imageEdit以及如何存图片到数据库 z

    http://blog.csdn.net/haoyujie/article/details/41277703 首先建立了一个数据库的表,这个表中,有一个字段是image类型(SQL Server数据库 ...

  4. [DevExpress] - 在 DataGrid 中添加多选复选框的方法

    设置方法 在 GridView 中设置 OptionSelection 属性如下: 效果 参考资料 https://stackoverflow.com/a/9078848http://blog.csd ...

  5. 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 ...

  6. csharp: Data binding in WPF DataGrid control

    <Window x:Class="WpfProjectDemo.MainWindow" xmlns="http://schemas.microsoft.com/wi ...

  7. easyui datagrid 增删改查示例

    查询JSP页面 <!doctype html> <%@include file="/internet/common.jsp"%> <!-- 新样式右侧 ...

  8. Easy-UI 动态添加DataGrid的Toolbar按钮

    在前人的基础上进行的修改,不知道他是从哪里引用来的,所以没有粘贴引用地址. 原代码不支持1.3.6. 修改功能: 1.如果之前没有添加过工具,用这个方法不能添加(已修复): 2.估计是不支持1.3.6 ...

  9. VS2010 MFC DataGrid绑定实例

    VS2010环境下MFC使用DataGrid绑定数据源 参考:http://blog.csdn.net/fddqfddq/article/details/7874706 详细介绍如何在MFC中使用Da ...

随机推荐

  1. ios隐藏导航栏底线条和导航、状态栏浙变色

    方法一遍历法: 在你需要隐藏的地方调用如下代码 [self findlineviw:self.navigationBar].hidden = YES; -(UIImageView*)findlinev ...

  2. 版本控制:集中式 vs 分布式

    集中式 CVCS的版本库集中存放在中央服务器,而工作时都是用自己的电脑,所以要先从中央服务器取得最新的版本,然后工作完后再将自己的代码推送给中央服务器. CVS:最早的.开源.免费.由于自身设计的问题 ...

  3. 【转】字符编码笔记:ASCII,Unicode和UTF-8

    今天整理笔记,关于NSString转NSData时,什么时候使用NSUTF8StringEncoding,或者NSASCIIStringEncoding,或者 NSUnicodeStringEncod ...

  4. OC-手动内存管理

    一.为什么要进行内存管理 •移动设备的内存极其有限,每个app所能占用的内存是有限制的 • •下列行为都会增加一个app的内存占用 Ø创建一个OC对象 Ø定义一个变量 Ø调用一个函数或者方法 • •当 ...

  5. "ERR_GFX_D3D_INIT", GTA5-报错解决办法

    GTA5 PC 版,online模式报错“ERR_GFX_D3D_INIT”. 网上搜到一篇文章,可以解决此问题: http://fixcrasheserrorguide.com/fix-grand- ...

  6. 10.14_魅族手机音乐播放无故暂停,MetroUICss-tile中的字如何居中

    (1)魅族手机,播放音乐,无故暂停.不管是自带的音乐播放程序,还是下载的其他音乐播放器都是如此.而且,手机上有个Google服务耗电量非常高,会经常弹出登陆Google账号的弹出项. (2)Metro ...

  7. 国庆第三天2014年10月3日10:21:39,Nutz,WebCollector,jsoup

    (1)做得好,做得快,只能选择一样. (2)时间过得很快,你没法在假期的一天里完成更多的计划.假期全部由自己支配,相对长一点的睡眠,新加入的娱乐(视频或者游戏),你不比在工作中更有效率. (3)每天练 ...

  8. What is the Xcopy Command?:

    Quote from: http://pcsupport.about.com/od/commandlinereference/p/xcopy-command.htm The xcopy command ...

  9. 怎么样调试正在运行的exe?

    最近在调虚幻的编辑器的时候遇到了一个问题. 调试模式运行UE4Editor.exe 实际上只是一个带参的命令行. 打开后,它又通过这个参数生成了一份详细配置,重新调用了自己.如图 这就悲剧了,断点都没 ...

  10. ThinkPHP下使用Ueditor

    在做课程设计的时候想到用百度的Ueditor,可在配置的时候出现了一些问题 Ueditor感觉不是很难,以前有个人定制的,现在取消了这项服务,但是我们可以自己进行配置 下载地址:http://uedi ...