Ankit Agarwal

Ankit Agarwal

  • NA
  • 379
  • 253.1k

How to display image in datagridview multiple rows in c#?

Dec 9 2013 4:49 AM
Hello,
 
I am using this code for image display but same images are displaying in all rows, but my images are different for every row.
private void CreateColumns()
        {
            DataGridViewImageColumn imageColumn;
            Bitmap bmpImage = null;
            imageColumn = new DataGridViewImageColumn();
            
            for (int i = 0; i < dgvDisplayTiles.Rows.Count;i++ )
            {
 
                bmpImage = (Bitmap)Image.FromFile(Application.StartupPath + dgvDisplayTiles.Rows[i].Cells[3].Value.ToString(), true);
                imageColumn.Image = bmpImage;
                imageColumn.ImageLayout = DataGridViewImageCellLayout.Stretch;
                
                
                dgvDisplayTiles.Rows[i].Cells[3].Value = bmpImage;
                dgvDisplayTiles.Rows[i].Height = 100;
                
            }
            dgvDisplayTiles.Columns.Add(imageColumn);
 
        }
Please help me, how can display different type of images in all rows.
 
Thanks in Advance.
 
Ankit Agarwal
Software Engineer

Answers (1)