• 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. C#微信开发之旅--基本信息的回复

    上一篇说到配置和验证<C#微信开发之旅--准备阶段> 下面来实现一下简单的信息回复. 也就是接收XML,返回XML 可以去看下微信开发文档的说明:http://mp.weixin.qq.c ...

  2. javascript变量,类型 第9节

    1.变量,数据类型 <html> <head> <title>变量</title> </head> <body> <h3& ...

  3. Universal Naming Convention (UNC)

    Quote from: http://compnetworking.about.com/od/windowsnetworking/g/unc-name.htm Definition: UNC is a ...

  4. c语言中继承和多态的简单实现

    C语言本身是不支持继承和多态的,但其实在 C 的世界里,有一套非常有名的面向对象的框架,用的也非常广,那就是 GObject,它是整个图形界面开发库 GTK 的基石,在IBM developerWor ...

  5. Java中静态代码块,代码块,构造方法的理解

    直接贴代码 class A { static { System.out.println("父类静态代码区"); } { System.out.println("父类代码区 ...

  6. C# 时间与时间戳互转

    /// <summary> /// 将c# DateTime时间格式转换为Unix时间戳格式 /// </summary> /// <param name="t ...

  7. js获取json数据

    var json = {  contry:{ area:{ man:"12万",  women:"10万" } } };//方式一:使用eval解析  var  ...

  8. c++与C# winform的消息通讯--(结构体与byte数组的使用)

    近期正在做一个蓝牙驱动的使用程序,其中有一块从c++发送数据到C#的部分,网上查了很多资料,大多都是介绍如何通过调用函数获取用户数据.并且在消息发送中,很少介绍如何发送一个结构体,并且结构体里面有 b ...

  9. Swift语言 1小时速学教程

    本文由 张渊杰 (网名寂静)编写 Swift语言 1小时速学教程 写在前面的话 有些人可能想, 呵呵, 1小时学一门语言, 你不是搞笑吧, 我想说, 是的, 完全可以, 就要看你怎么学了 要想在1小时 ...

  10. mysql 存储引擎 myisam innodb 区别

    虽然MySQL里的存储引擎不只是MyISAM与InnoDB这两个,但常用的就是它俩了.可能有站长并未注意过MySQL的存储引擎,其实存储引擎也是数据库设计里的一大重要点,那么博客系统应该使用哪种存储引 ...