c# - 如何在我的 DataGridViewImageColumn 中添加图像?

标签 c# image datagridview

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

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. 以这种方式添加图像:

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

关于c# - 如何在我的 DataGridViewImageColumn 中添加图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17365965/

相关文章:

c# - 在 datagridview 中插入之前防止重复

c# - DataGridView 单元格

c# - 如何通过 GetPixel 方法比较颜色和通过 Color.Black 等方法传递的颜色?

c# - 当用户开始编辑单元格文本时,如何以编程方式将光标放在文本的开头以编程方式编辑 DataGridView 单元格?

c# - 为 dataGridView 中的特定列设置默认列值

c# - Xamarin.Forms:应用程序关闭时广播接收器不工作

c# - LINQ 按 x 列排序,如果为空则按 y 列排序

c# - 如何计算wpf中形状的方向

javascript - 如何使用链式 Promise 加载图像

java - 显示图像