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 ...
随机推荐
- java面试入门总结
最近正好有时间空下来,前一段时间本来打算呢,写一写阶段的总结,今天就来谈谈吧.作为一个java入门小白,之前就职于浙江大华,是通过大华10月份秋季招聘通过大华的面试. 浙江大华校招采用模式是先笔试.再 ...
- 自己在使用的English词典
一.ESL/非母语词典 二.EFL/母语词典 1.American Heritage Dictionary 2.World Book Dictionary 3.Oxford Dictionary of ...
- /etc/rc.local ; /etc/init.d ;/etc/profile;/etc/bashrc;~/.bash_profile;~/.bashrc;~/.bash_logout
1. /etc/rc.local 这是使用者自订开机启动程序,把需要开机自动运行的程序写在这个脚本里. 把脚本程序写在/etc/rc.d/init.d/目录下也可以 在完成 run level 3 ...
- ASP.NET MVC5 easyui 之 treegrid 初用记录
菜鸟初次使用,参考论坛中介绍的方法仍走了一些弯路,把自己遇到的问题记录下来. 1.必须定义根节点: 2.根节点一个或多个均可: 4.根节点的父节点属性不必定义,或者定义为0: 5.各级子节点的父节点属 ...
- php 验证码生成方法 及使用
基本思路是: 在生成图片的页面中(as: yzm.php)1.设置生成的图片的宽度和高度:2.设置图片要写入的字符:3.截取显示在图片上的字符;4.开启session,把上面截取的字符存放在sessi ...
- 设置Android程序的默认安装位置
修改 AndroidManifest.xml 文件: <manifest xmlns:android="http://schemas.android.com/apk/res/andro ...
- SQL函数:小写金额转换成大写
/********************************************************作者:版本:1.0创建时间:20020227修改时间:功能:小写金额转换成大写参数:n ...
- C语言全局变量的定义与声明
C语言中全局变量的定义与声明困扰着许多C语言初学者.本文讲述了全局变量定义与声明的用法,而且本为也将阐述这种用法的内在原理.我们先从两个错误例子引入,以下两个例程都在vc6.0平台上测试. 两种错误例 ...
- 在ubuntu中获得root权限
在终端中输入:(1)sudo passwd rootEnter new UNIX password: (在这输入你的密码)Retype new UNIX password: (确定你输入的密码)pas ...
- xmpp 配置数据库 服务器
一.了解XMPP 协议(标准) XMPP 即时通讯协议 SGIP 短信网关协议 这手机发短信 移动支付和网页支付 0x23232[0,1] 0x23232 0x23232 0x23232 只有协议,必 ...