display image in gridviewcomboboxcolumn

2 posts, 0 answers
  1. Ameya
    Ameya avatar
    2 posts
    Member since:
    May 2012

    Posted 02 May 2012 Link to this post

    Posted 4 hours ago (permalink)

    Hello Friends,

    I following field in sql database for  IMage_master 

    1) Imageid (numeric(18,0))
    2) Image_code (nvarchar(100))
    3) fullimage (image) -- I store image with 100 kb

    I am doing windows application with C# and Sql2008 as backend

    I have gridviewcomboboxcolumn with name cmbimage with display member fullimage and value member as image code. Its not sowing image its just showing byte[]. i want to display image in   gridviewcomboboxcolumn  .

    Please help me out , if possible with code

    With Regards

    Ameya Chavan
  2. Stefan
    Stefan avatar
    2891 posts

    Posted 07 May 2012 Link to this post

    Hello Ameya,

    Thank you for writing.

    Please refer to the following helper methods, which you can use to convert a byte[] to an image:
    private Image GetImageFromData(byte[] imageData)
        const int OleHeaderLength = 78;
        MemoryStream memoryStream = new MemoryStream();
        if (HasOleContainerHeader(imageData))
            memoryStream.Write(imageData, OleHeaderLength, imageData.Length - OleHeaderLength);
            memoryStream.Write(imageData, 0, imageData.Length);
        Bitmap bitmap = new Bitmap(memoryStream);
        return bitmap.GetThumbnailImage(55, 65, null, new IntPtr());
    private bool HasOleContainerHeader(byte[] imageByteArray)
        const byte OleByte0 = 21;
        const byte OleByte1 = 28;
        return (imageByteArray[0] == OleByte0) && (imageByteArray[1] == OleByte1);

    I hope you find this information useful.

    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. DevCraft R3 2016 release webinar banner
Back to Top