This is a migrated thread and some comments may be shown as answers.

display image in gridviewcomboboxcolumn

1 Answer 92 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ameya
Top achievements
Rank 1
Ameya asked on 02 May 2012, 10:03 AM


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

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 07 May 2012, 08:55 AM
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);
    }
    else
    {
        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.

Regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Ameya
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or