日期:2014-05-17 浏览次数:21258 次
private void demoGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (demoGrid.Columns[e.ColumnIndex].Name.Equals("Image"))
{
string path = System.Windows.Forms.Application.StartupPath + @"/1.gif";
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;
}
------解决方案--------------------
模版列的使用,在模版列中使用<a href='<%# ~/imgpath/Eval("img") #'>img</a>将连接绑定好!
------解决方案--------------------