I have a DataGridView bound to a DataTable on my Windows Form. I want to insert an unbound DataGridViewImagecolumn to it and set the images according to the value of another column. Image is set in DataGidView_CellFormating event. Code is as follows
DataGridView dgvResult = new DataGridView();
dgvResult.DataSource = dtResult;
DataGridViewImageColumn imageColumn = new DataGridViewImageColumn();
imageColumn.Width = 40;
imageColumn.Name = "Image";
imageColumn.HeaderText = "";
dgvResult.Columns.Insert(0, imageColumn);
private void dgvResult_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dgvResult.Columns[e.ColumnIndex].Name == "Image")
{
DataGridViewRow row = dgvResult.Rows[e.RowIndex];
if (Utils.isNumeric(row.Cells["CM_IsExport"].Value.ToString()) && Int32.Parse(row.Cells["CM_IsExport"].Value.ToString()) == 1)
{
row.Cells["Image"].Value = Properties.Resources.export16;
}
else { row.Cells["Image"].Value = Properties.Resources.plain16; }
}
}
Everything is working fine. My problem is that the images shown in cells are flickering. Anybody know why?