我将数据表绑定到datagridview,每列显示正确的数据。但是在我的图像列中,datagridview中没有显示图像,而是显示了System.Drawing.Bitmap字符串。
我的代码是;
// I create the data column for my Image and add this to the datatable
DataColumn dc = new DataColumn("QR Code", typeof(Image));
dc.AllowDBNull = true;
dTable.Columns.Add(dc);
// I loop through all rows in datatable get the byte array of the image, and convert it to an Image
// And then add this image to the newly created column.
foreach (DataRow dr in dTable.Rows)
{
Image qrCode;
byte[] qrCodeBytes = (byte[])dr["StockQRCode"];
using(MemoryStream stream = new MemoryStream(qrCodeBytes))
{
qrCode = Image.FromStream(stream);
dr[dc] = qrCode;
}
}
// Bind my datatable to datagridview
List_ListContainer.DataSource = dTable;
我错过了什么?