Selecting/disabling pictureBoxes.

J

Jesse

I've got a bunch of PictureBoxes on a form. People can click on them to
"select" them. I'm trying to figure out how to show three different states:
unselected, selected, disabled ("grayed out").

Basically, I want to apply (and later undo) a color transformation to the
whole image. Is there a good way to do it?

Thanks!


The best I could come up with was to draw a frame around the picture, but I
ran into Z-order problems, where the rectangle I drew got overdrawn by
another control next to the PictureBox. No idea how to fix that, either...

rect = myPictureBox.Bounds
rect.Inflate(1, 1)
e.Graphics.DrawRectangle(myPen, rect)

--
 
G

Guest

Well, instead of using a PictureBox, you could use a panel and draw an image
on it yourself. If you do so using Graphics.DrawImage, you can supply
ImageAttributes. Using ImageAttributes, you can do all kinds of color
transformations on an image. You can use a color remap table, but you can
also use color matrices to do transformations.

Here's an article that explains a bit on how it could work:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbdev05/html/vb05f17.asp

Hope this answers your question.

Regards,
Jelle
 
J

Jesse

Thanks, Jelle! That was perfect -- by putting the images on a grey
background, then setting their opacity to 50%, I get a "greyed out" look.
 
G

Guest

I've also found this method which may be even better suitable:

ControlPaint.DrawImageDisabled
 

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