我正在尝试通过代码甚至在设计时将图像添加到 DataGridViewImageColumn
它总是出现带有“x”表示没有图像的默认 c# 图像
我试过微软的这段代码
Icon treeIcon = new Icon(this.GetType(), "tree.ico");
DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
iconColumn.Image = treeIcon.ToBitmap();
iconColumn.Name = "Tree";
iconColumn.HeaderText = "Nice tree";
dataGridView1.Columns.Insert(2, iconColumn);
.但是我在资源中添加了一个 .ico - 还尝试了文件路径 - 异常结果表明在表单类中找不到 tree.ico
我用图像替换了图标
ataGridViewImageColumn img = new DataGridViewImageColumn();
img.ValuesAreIcons = true;
Image image = Image.FromFile("C:/Users/../Desktop/app_edit.png");
img.Image = image;
showprocessed_dataGridView.Columns.Add(img);
img.HeaderText = "Image";
img.Name = "img";
这导致 ataGridViewImageColumn 中显示默认的“无图像”,这个问题的解决方案是什么?是图片格式的问题还是什么!!任何帮助,将不胜感激 ..