Violeta Popa

Violeta Popa

  • NA
  • 137
  • 164.1k

image in datagridview

Apr 15 2013 4:00 PM
Hello :)

I'm trying to display image in datagridview cells, depending on a condition. My code seems right but i don't know why it doesn't display anything.

for (int k = 0; k <= calculGridView.Rows.Count-1; k++)
            {
                Image img;
                DataGridViewImageCell cell = (DataGridViewImageCell)calculGridView.Rows[k].Cells["image"];//image is a datagridviewimagecolumn
                if (calculGridView.Rows[k].Cells["societate"].Value.ToString() == "BetaCar")
                {              
                    img = Image.FromFile(@"C:\\Users\\Vio\\Desktop\\New folder\\betacar.jpg");
                    cell.Value = img;
                }
            }
Does anybody know what's wrong? or maybe another solution?

Answers (3)