dataGridView1的超链接显示图片 本帖最后由 winamw 于 2012-10-07 15:07:30 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用模板列,并使用Image控件来显示你的图片地址<ItemTemplate> <img src='<%# Eval("imgurl") %>'</ItemTemplate> 或是参考下面:http://social.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/bc682f72-33ce-4841-97e3-8a859bcea3bb 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>将连接绑定好! Mono For Android的奇怪问题 怎么让下拉列表记住用户名 急,数据库操作老是不成功... C#操作注册表拒绝怎么办?win7系统! 战棋类地图处理 急!找不到类型或命名空间名称“Server”(是否缺少 using 指令或程序集引用?) 这个窗体如何关掉呢 一个枚举的问题?(在线等待!!) C#中的图像处理 C#中如何读取文本方式的整数 象C++中的fscanf语句一样 C#和java是什么关系?为什么那么像呢? 如何将鼠标移动到,webbrowser控件上指定的标签上。
<img src='<%# Eval("imgurl") %>'
</ItemTemplate> 或是参考下面:
http://social.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/bc682f72-33ce-4841-97e3-8a859bcea3bb
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;
}