How do I add an image in my DataGridViewImageColumn?
- Add your image in Resources.resx under properties folder. (ex. Picture1.jpeg)
- Add a
DataGridViewImageColumn
in yourDataGridView
Add image this way:
for (int row = 0; row <= [YourDataGridViewName].Rows.Count - 1; row++) { ((DataGridViewImageCell)gvFiles.Rows[row].Cells[1]).Value = Properties.Resources.Picture1 }
use this code:
DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
iconColumn.Name = "AirplaneImage";
iconColumn.HeaderText = "Airplane Image";
dataGridView1.Columns.Insert(5, iconColumn);
for (int row = 0; row < dataGridView1.Rows.Count - 1; row++)
{
Bitmap bmp = new Bitmap(Application.StartupPath + "\\Data\\AirPlaneData\\" + dt.Rows[row][4]);
((DataGridViewImageCell)dataGridView1.Rows[row].Cells[5]).Value = bmp;
}