如何在Datagridview中为Image Column提供超链接

时间:2011-03-03 10:30:01

标签: c# winforms datagridview

如何在win窗体中超链接到DataGridViewImageColumn?

OPs评论的代码示例:

DataGridView dgv = new DataGridView();
dgv.Name = "dgv" + i;
dgv.DataSource = dsMain.Tables[0];
dgv.Dock = DockStyle.Fill;
dgv.AllowUserToAddRows = false;

DataGridViewImageColumn img = new DataGridViewImageColumn();

Image image = Image.FromFile("C:\\Small.jpg");
img.Image = image;
img.ImageLayout = DataGridViewImageCellLayout.Normal;
dgv.Columns.Add(img);
img.HeaderText = "";
img.Name = "img";

tp.Controls.Add(dgv);

1 个答案:

答案 0 :(得分:0)

您希望链接做什么?打开网页?

只需在图片中添加点击处理程序。