M
mj2736
I'm trying to display a GIF image in a DataGridViewImageColumn when a
certain condition is true, and nothing when it is false:
private void dgvInbox_DataSourceChanged(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dgvInbox.Rows)
{
DataGridViewImageCell todayCell =
(DataGridViewImageCell) row.Cells["TodayIndicator"];
if (DateTime.Now.Date == (DateTime) row.Cells["ItemDate"].Value)
{
todayCell.Value = Image.FromFile(@"Images\Exclamation.gif");
}
else
{
todayCell.Value = null;
}
}
}
When stepping through the code, the appropriate lines to set the cell
value are being hit, but in all cases (both true and false) the default
[X] graphic is displayed. I know the file path is correct because I do
not get a FileNotFoundException. I've tried setting the ValueIsIcon and
ValueType properties of the cell and of the column, but I've not yet
found a combination that works.
Thanks!
MJ
certain condition is true, and nothing when it is false:
private void dgvInbox_DataSourceChanged(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dgvInbox.Rows)
{
DataGridViewImageCell todayCell =
(DataGridViewImageCell) row.Cells["TodayIndicator"];
if (DateTime.Now.Date == (DateTime) row.Cells["ItemDate"].Value)
{
todayCell.Value = Image.FromFile(@"Images\Exclamation.gif");
}
else
{
todayCell.Value = null;
}
}
}
When stepping through the code, the appropriate lines to set the cell
value are being hit, but in all cases (both true and false) the default
[X] graphic is displayed. I know the file path is correct because I do
not get a FileNotFoundException. I've tried setting the ValueIsIcon and
ValueType properties of the cell and of the column, but I've not yet
found a combination that works.
Thanks!
MJ