如何在DataGridViewImageColumn中添加图像? [英] How do I add an image in my DataGridViewImageColumn?

查看:568
本文介绍了如何在DataGridViewImageColumn中添加图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字段 DataGridViewImageColumn ,对于该字段的每一行,根据条件,我添加了一个不同的图像。有人知道如何在Windows窗体中执行此操作吗?

I have a field DataGridViewImageColumn, and for each line of the field, depending on a condition, I add a different image. Anyone know how I can do this in Windows Forms?

if (dgvAndon.Rows[e.RowIndex].Cells["urgencyOrder"].ToString() == "1")
{
   //Here I want to add the image in the image property field DataGridViewImageColumn.
}


推荐答案


  1. 在属性文件夹下的Resources.resx中添加图像。 (例如Picture1.jpeg)

  2. DataGridView 中添加 DataGridViewImageColumn

  3. 以这种方式添加图像:

  1. Add your image in Resources.resx under properties folder. (ex. Picture1.jpeg)
  2. Add a DataGridViewImageColumn in your DataGridView
  3. Add image this way:

for (int row = 0; row <= [YourDataGridViewName].Rows.Count - 1; row++)
{
    ((DataGridViewImageCell)gvFiles.Rows[row].Cells[1]).Value = Properties.Resources.Picture1
}


这篇关于如何在DataGridViewImageColumn中添加图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆