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?
Does anybody know what's wrong? or maybe another solution?

VulpesPosted Apr 16, 2013, 9:49 AM
Are you sure are the cell contains "BetaCar" and not "Beta Car" (or the same word(s) with different casing) and that there's no white-space at the end which needs trimming off before the comparison is made?
Violeta PopaPosted Apr 16, 2013, 2:52 AM
VulpesPosted Apr 15, 2013, 5:20 PM
img = Image.FromFile(@"C:\\Users\\Vio\\Desktop\\New folder\\betacar.jpg");
you don't want the @ in front because the backslashes have been doubled.