This is a migrated thread and some comments may be shown as answers.

How to use Transparent PNG as image for buttons?

5 Answers 550 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Afraz Ali
Top achievements
Rank 1
Afraz Ali asked on 08 Sep 2010, 09:27 AM
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

5 Answers, 1 is accepted

Sort by
0
Vassil Petev
Telerik team
answered on 09 Sep 2010, 10:24 AM
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
0
Afraz Ali
Top achievements
Rank 1
answered on 15 Sep 2010, 05:09 AM
Hi Vassil ,

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

Regards,
Syed Afraz Ali
0
Stefan
Telerik team
answered on 20 Sep 2010, 04:12 PM
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
0
Piyush Bhatt
Top achievements
Rank 2
answered on 13 Jul 2011, 01:12 PM
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.
0
Stefan
Telerik team
answered on 15 Jul 2011, 03:00 PM
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!

Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Afraz Ali
Top achievements
Rank 1
Answers by
Vassil Petev
Telerik team
Afraz Ali
Top achievements
Rank 1
Stefan
Telerik team
Piyush Bhatt
Top achievements
Rank 2
Share this question
or