private void dataGridview1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dataGridview1.Columns[e.ColumnIndex].Name.Equals("Image"))
{
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;
}
使用DataGridViewImageColumn
DataGridViewImageColumn column = new DataGridViewImageColumn();
dataGridView1.Columns.Add(column);
column.HeaderText = "图片";
column.Image = System.Drawing.Image.FromFile("路径");
((DataGridViewImageCell)this.dataGridView1.Rows[e.RowIndex].Cells[ "图片列"]).Value = "路经 "
去年弄的一次记的不是很清楚大约是这样
绑定或不绑定
若要绑定,,则每列数据都要是绑定来的数据,包括图片列
所以图片列也要对应于数据库中的图片列
还有就是不绑定,这个要用循环一行一行的处理每个格中的数据,不过很灵活
http://topic.csdn.net/u/20091229/05/98361fa9-1aea-48ec-b6e5-a5025cbbfb15.html