3

我有一个包含人名、姓氏、代码和照片的人员数据表。当我从表中选择人员并将结果发送到 DevExpress GridControl 时,它会显示姓名、姓氏和代码列。但 Photo 列在所有行中显示 System.Byte[] 值。问题是什么。

4

2 回答 2

6

您应该为列的ColumnEdit属性分配一个RepositoryItemPictureEdit的实例。在这种情况下,XtraGrid 将能够在网格中显示图像。

示例:如何在 GridControl 中显示图像

相关链接:

  1. 存储库和存储库项
  2. 就地编辑器概述
于 2012-08-23T12:05:03.487 回答
0

***字节转换为图像

           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);     
于 2013-01-27T07:26:41.970 回答