如何包括DevExpress的DataGrid中的图像 [英] How include a image in devexpress datagrid

查看:184
本文介绍了如何包括DevExpress的DataGrid中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在开发设置图标根据从数据库返回的值表示数据网格

How can set icon in Dev express data grid depending on the value returning from Database

推荐答案

下面是步骤。


  • 添加ImageCollection到YOUT形式和16x16的添加一些图标吧。

  • 添加一列网格的图标。

  • 设置列的字段名图像(无论
    你喜欢)。

  • 设置列的UnboundType到对象。

  • 添加repositoryItemPictureEdit至
    列的columnEdit。

  • 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

private void 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];
        }
    }
}



这里的关键是处理 CustomUnboundColumnData 和repositoryItemPictureEdit。

The key here is handling the CustomUnboundColumnData and the repositoryItemPictureEdit.

这篇关于如何包括DevExpress的DataGrid中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆