如何在DataGridViewImageColumn中添加图像?

Flá*_*sta 8 c# datagridview image

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

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

Man*_*noj 8

  1. 在属性文件夹下的Resources.resx中添加图像.(例如Picture1.jpeg)
  2. DataGridViewImageColumn在你的.添加一个DataGridView
  3. 以这种方式添加图片:

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