Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I bound my datatable to datagridview, every column shows the correct data. But on my Image Column in datagridview does not show the image, instead it shows System.Drawing.Bitmap string.

What am I missing?

Thanks in advance...

What I have tried:

C#
<pre>My codes are;

<pre lang="c#">
// 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;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900