How can I hide individual images in a DataGridViewImageColumn

Q

Quick

I have a DataGridView that has a DataGridViewImageColumn.

The image that renders in the column needs to only be visible when a
certain value is present within another column in the DataGridView.

I can't seem to figure out what it would take to make this happen.
Just about every property I can find to use on the individual cell that
deals with display is Read Only.

Here's what I've got so far:

foreach (DataGridViewRow row in dgEmployees.Rows) {
if (row.Cells[15].Value.ToString().Trim() == "") {
row.Cells[3]. ((remove/hide the image in this cell of the
current row))
}
}

I can't imagine this is an uncommon thing to do, so I'm figuring I'm
just overlooking something simple or I'm going about it the wrong way.

Any ideas would be greatly appreciated.

-Quick
 
Q

Quick

I got it. Yeah I was going about it the wrong way.

((DataGridViewImageCell)row.Cells[3]).Value = new Bitmap(1, 1);

Casting the current cell as a DataGridViewImageCell then changing its
value to a blank Bitmap object seemed to work. Although if anyone has
a better way of accomplishing this I'd like to see it as well.

-Quick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top