Can I set a transparent color for an image?

I have an image which I use on a toolstrip button which has cyan set as the transparency color. When I display the image on the button I can get it to display the image without the cyan pixels - so it draws a circle without the background for example.

When I create a label on a form and set the same image to be displayed without any text there appears to be no way to stop it from displaying the cyan background to the circle. The properties available for label are not the same set of properties for a toolstrip button.

Is there some way I can display the circle on the form without the cyan background?  I could choose to set the background to be the background color for the form but this has two problems. 1. I then need to maintain two images(one for the toolstrip button and one for the form). 2. If I change the background color of the form dynamically I can't change the background color of the circle to match.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Try settiong the TransparencyKey property of the Form to the color Color.Cyan
wsprhinoAuthor Commented:

Setting the TransparencyKey just means that the background of the image is displayed as the color of the form that underlies the form on which the control lies.

Also, I have a case in which the image is placed on a control which in turn is placed on a form and the control does not have TransparencyKey property.

I could read the resource bitmap and convert all the cyan pixels to the current background color of the form. But, this seems like a sledgehammer approach. I have tried using controls other than labels but they all have the same problem. Buttons, picture boxes both have the same problem. It is a pity MS cannot provide a consistent interface where we have the same control over label images as we do with toolstrip button images. It also means that I need to regenerate the bitmap each time the forms background color is changed.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.