Can I set a transparent color for an image?

Posted on 2008-11-16
Last Modified: 2013-12-17
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.


Question by:wsprhino
    LVL 62

    Expert Comment

    by:Fernando Soto
    Try settiong the TransparencyKey property of the Form to the color Color.Cyan

    Accepted Solution


    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.


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now