DataGridView Image Columns

  • Thread starter Thread starter CAC90
  • Start date Start date
C

CAC90

Guest
I have been pulling my hair out on this one and decided it was time to post it here after Googling for countless hours without finding an answer to my problem.

I have a simple databound datagridview that I am trying to display an image on a cell by cell basis based on the cell value (stop, started, finished) etc.. The values are int values and so far I have been able to get it to work but I have noticed lots of flickering while using the grid and lots of mismatched images being displayed for the underlying cell value. Any help would be much appreciated...

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)

{

if (e.ColumnIndex == 2)

{

DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];

DataGridViewCell cell = row.Cells[1];

if ((int)cell.Value == 2)

{
DataGridViewImageColumn col = (DataGridViewImageColumn)this.dataGridView1.Columns[2];


col.Image = Data_Grids.Properties.
Resources.ProcessRestartedS.ToBitmap();

}

else

{

DataGridViewImageColumn col = (DataGridViewImageColumn)this.dataGridView1.Columns[2];

col.Image = Data_Grids.Properties.
Resources.ProcessRunningS.ToBitmap();

}

}


}

Continue reading...
 
Back
Top