我有一个字段 DataGridViewImageColumn
,根据条件,我为字段的每一行添加不同的图像。有人知道我如何在 Windows 窗体中执行此操作吗?
if (dgvAndon.Rows[e.RowIndex].Cells["urgencyOrder"].ToString() == "1")
{
//Here I want to add the image in the image property field DataGridViewImageColumn.
}
最佳答案
- 将您的图像添加到属性文件夹下的 Resources.resx 中。 (例如 Picture1.jpeg)
- 在您的
DataGridView
中添加一个DataGridViewImageColumn
以这种方式添加图像:
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/