dataGridView1的超链接显示图片

朝三暮四 2012-10-07 03:03:02
dataGridView1 图片列的超链接 直接显示图片
超链接地址:c:\jkd.jpg
...全文
258 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
IT0329 2012-10-08
  • 打赏
  • 举报
回复
alasunny 2012-10-08
  • 打赏
  • 举报
回复
模版列的使用,在模版列中使用<a href='<%# ~/imgpath/Eval("img") #'>img</a>将连接绑定好!
熙风 2012-10-07
  • 打赏
  • 举报
回复

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;
}
暖枫无敌 2012-10-07
  • 打赏
  • 举报
回复
使用模板列,并使用Image控件来显示你的图片地址

<ItemTemplate>
<img src='<%# Eval("imgurl") %>'
</ItemTemplate>

或是参考下面:
http://social.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/bc682f72-33ce-4841-97e3-8a859bcea3bb
酷毙高手 2012-10-07
  • 打赏
  • 举报
回复
说的详细一点

109,886

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧