Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This code is not showing image in datagrid view i am not sure what is going wrong please help me

What I have tried:

C#
while(rdr.Read())
            {
        DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
                 ImageConverter ic;
                 Image img;
               Byte[] cbyte;
                  ic = new ImageConverter();
                  cbyte = (Byte[])(rdr["Imge"]);
                 img = (Image)ic.ConvertFrom(cbyte);
                Bitmap a = new Bitmap(img);
                 iconColumn.Image = a;
                 iconColumn.Name = "Tree";
                 iconColumn.HeaderText = "Nice tree";
                 dataGridView1.Columns.Insert(0, iconColumn);
            };
Posted
Updated 25-Sep-16 6:24am
v2
Comments
[no name] 25-Sep-16 11:08am    
Learn to use the debugger and debug your code. Then you would know what is going on.
Sinisa Hajnal 26-Sep-16 6:56am    
Set a breakpoint to cbyte line and step through the code until you find the problem.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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