I need to hide or show images for individual cells in a DataGridViewImageColumn. I put the code in cell formatting event. But I have no idea how to hide images from cells. The only way I know how to remove images would be first set the image column's Image property to null and then set each cell's image to some images for display. But this is a bit inconvenient because the image show/hide code is now in my cell formatting event.
Anyone knows easy way to hide/remove images from individual cells? Thanks.
I was just searching for the solution to the same problem and the one I've settled for the following:
if (showImage == true)
{
imageCell.Value = new Bitmap(iconPath);
}
else
{
imageCell.Value = new Bitmap(1, 1);
}
If the background of your cell is white the 1x1 bitmap won't be visible. Otherwise you'll have to color that pixel according to your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With