[英]DevExpress GridControl image column displays images like System.Byte[]
我有一個人員數據的表格,名稱,姓氏,代碼和人物照片。 當我從表中選擇人員並將結果發送到DevExpress GridControl時,它會顯示Name,Surname和Code列。 但Photo列顯示所有行中的System.Byte []值。 問題是什么。
您應該為列的ColumnEdit屬性分配一個RepositoryItemPictureEdit實例。 在這種情況下,XtraGrid將能夠在網格中顯示圖像。
相關鏈接:
***字節轉換為圖像
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.