How to use Transparent PNG as image for buttons?

6 posts, 0 answers
  1. Afraz Ali
    Afraz Ali avatar
    12 posts
    Member since:
    Jul 2009

    Posted 08 Sep 2010 Link to this post

    Hi,

    I have a PNG image (round button) and I want to use that as button. I have tried setting the image property to that image in radButton control but it shows the transparent area as well. My Question is how can I use round images as buttons and is the procedure for using transparent images same for all controls?

    Thanks
    Afraz Ali
  2. Vassil Petev
    Admin
    Vassil Petev avatar
    1765 posts

    Posted 09 Sep 2010 Link to this post

    Hello Afraz Ali,

    Our image handling mechanism is the same as the standard WinForms controls. Try adding a transparent image to the standard button and use the same logic in the Telerik WinForms button.


    Greetings,
    Vassil
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Afraz Ali
    Afraz Ali avatar
    12 posts
    Member since:
    Jul 2009

    Posted 15 Sep 2010 Link to this post

    Hi Vassil ,

    Could you please tell me a step by step mechanism for this?

    Regards,
    Syed Afraz Ali
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 20 Sep 2010 Link to this post

    Hi Afraz Ali,

    Although this question is not related to our tools, we will address it any way, just to help you out.

    As noted, the steps to set an image in our tools is the same as setting an image in the standard MS controls. If you see the transparent area, then either your image is not transparent, or you have not set its background color to be transparent. The latter can be done through an ImageList:
    1. Add an ImageList component to your form
    2. Load the images into an imagelist.
    3. Go to the ImageLlist's properties and change the TransparentColor property to the background color that you would like to be transparent.
    4. Set ColorDepth to your png's color depth, usually Depth8Bit
    5. Assign the ImageList to the button via the button's ImageList property
    6. Go to the button's ImageKey property and select the image you would like to display
    7. Run the application to see the result

    If you still experience problems, please review the Microsoft Developer Network (MSDN) on how to work with transparent images.


    Greetings,
    Stefan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Piyush Bhatt
    Piyush Bhatt avatar
    166 posts
    Member since:
    Nov 2007

    Posted 13 Jul 2011 Link to this post

    as a 'sold' product, it would be a great benefit if the RadButton had off-the-shelf feature to make it look like an image button w/o much settings.

    I am also trying to set an image on the regular button and rad button - so that I can see just the image - but both of them show some background control color and not able to make it transparent. I set the control's BackColor property as well - but no luck.
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 15 Jul 2011 Link to this post

    Hello Piyush,

    Thank you for writing.

    You can set an image to RadButton and display only the image with two lines of code:
    button.Image = Image.FromFile(@"C:\image.png");
    button.AutoSize = true;

    I hope this helps.
     
    Kind regards,
    Stefan
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
UI for WinForms is Visual Studio 2017 Ready