简体   繁体   English

DevExpress GridControl图像列显示类似System.Byte []的图像

[英]DevExpress GridControl image column displays images like System.Byte[]

I have a table with person data which are Name, Surname, Code and Photo of persons. 我有一个人员数据的表格,名称,姓氏,代码和人物照片。 And when I select persons from table like and send the result to DevExpress GridControl it shows Name, Surname and Code columns. 当我从表中选择人员并将结果发送到DevExpress GridControl时,它会显示Name,Surname和Code列。 But Photo column displays System.Byte[] value in all rows. 但Photo列显示所有行中的System.Byte []值。 What is the problem. 问题是什么。

You should assign the column's ColumnEdit property with an instance of a RepositoryItemPictureEdit . 您应该为列的ColumnEdit属性分配一个RepositoryItemPictureEdit实例。 In this case, the XtraGrid will be able to show image in the grid. 在这种情况下,XtraGrid将能够在网格中显示图像。

Sample: How to display an image in GridControl 示例: 如何在GridControl中显示图像

Related links: 相关链接:

  1. Repositories and Repository Items 存储库和存储库项
  2. Inplace Editors Overview 就地编辑概述

***Byte Convert To Image ***字节转换为图像

           data.Read();

            //get the value of the size field in the current row and store it in filesize

            int fileSize = data.GetInt32(data.GetOrdinal("size"));

            //get the value of the name field in the current row and store it in filesize

            string name = data.GetString(data.GetOrdinal("name"));  

            //Create a byte array to read the file in the row which is in bytes

            byte[] rawData = new byte[fileSize];

            //Read the bytes and store it in the array

            data.GetBytes(data.GetOrdinal("file"), 0, rawData, 0, fileSize);

            //Create the file from the byte array which is read from the database

            FileStream fs = new FileStream(name, FileMode.Create, FileAccess.Write);

            fs.Write(rawData, 0, fileSize);

            //closing the file stream 

            fs.Close();

            //Showing the image that is just retreived in te picturebox picDB

            picDB.BackgroundImage = new Bitmap(name);     

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM