显示图片的列可以以路径的形式呈现
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.RowIndex > 2 && e.RowIndex < 7 &&
e.ColumnIndex == 显示图片的列索引)
{
string path = e.Value.ToString();
e.Value = GetImage(path);
}
}
public System.Drawing.Image GetImage(string path)
{
System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open);
System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
fs.Close();
return result;
}