隐藏DataGridViewImageColumn中的图像

Ste*_*eve 2 .net c# datagridview image winforms

我需要隐藏或显示DataGridViewImageColumn中单个单元格的图像.我把代码放在单元格格式化事件中.但我不知道如何从细胞中隐藏图像.我知道如何删除图像的唯一方法是首先将图像列的Image属性设置为null,然后将每个单元格的图像设置为一些图像以供显示.但这有点不方便,因为图像显示/隐藏代码现在在我的单元格格式化事件中.

有人知道隐藏/删除单个细胞图像的简单方法吗?谢谢.

mrt*_*mrt 5

我只是在寻找解决同样问题的解决方案,并且我已经解决了以下问题:

if (showImage == true)
{
    imageCell.Value = new Bitmap(iconPath);
}
else
{
    imageCell.Value = new Bitmap(1, 1);
}
Run Code Online (Sandbox Code Playgroud)

如果单元格的背景为白色,则1x1位图将不可见.否则,您必须根据需要为该像素着色.