• 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. Block中的引用循环

    原文地址:http://www.cnblogs.com/lujianwenance/p/5910490.html Block在实际的开发中非常的常用,事件回调.传值.封装成代码块调用等等.很多人都对b ...

  2. 使用AFNetworking进行图片上传

    转载自:http://blog.csdn.net/a645258072/article/details/51728806 项目中,我们经常会用到上传图片的功能,而目前的上传图片分为两种(我只知道两种, ...

  3. 摘录android工具类

    import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.Pac ...

  4. javaScript笔记1

    一.通过 id 访问HTML元素,可以使用 document.getElementById(id) 方法. 例子: <body> <button id="mybtn&quo ...

  5. [翻译][MVC 5 + EF 6] 1:创建数据模型

    原文:Getting Started with Entity Framework 6 Code First using MVC 5 1.新建MVC项目: 2.修改Views\Shared\_Layou ...

  6. go build 时报错 cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

    最近在玩Go win下尝试编译Go的时候遇到了下面提示(可能是gorocksdb用到了gcc) gcc也需要64位的 最后找到了个帖子: https://github.com/mattn/go-sql ...

  7. 用source code编译安装Xdebug

    1. Unpack the tarball: tar -xzf xdebug-2.2.x.tgz.  Note that you do not need to unpack the tarball i ...

  8. 简单Linq笔记

    Linq是.net 3.5才引入的 要引入命名空间System.Linq. Linq  to XML要引入System.Xml.Linq Linq to ADO.NET要引入System.Data.L ...

  9. which命令

    which指令会在PATH变量指定的路径中,搜索某个系统命令的位置,并且返回第一个搜索结果. 格式 which 可执行文件名称 参数 -V  显示版本信息 实例 用 which 去找出 which w ...

  10. xml之phpdom操作

    php xml编程XML解析技术介绍 1.php与DOM 2.PHP与XPath 3.SimpleXML DOM(document object model)文档对象模型 把一个文件看做一个对象模型, ...