Click here to Skip to main content
15,942,757 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

If I apply a PNG image with a transparent image to a button, will it be appear only the required area .. I am not getting that feature. Please suggest me how to that in C# Winforms.

Regards
Posted
Comments
Sergey Alexandrovich Kryukov 19-Jan-12 0:31am    
Is it just about non-rectangular button? You got the exact recipe then -- please see my answer.
--SA

1 solution

I'm not getting it, too. I mean this question. If you need your button to occupy "only the required" area, how it that related to the transparency. Do you simply want a non-rectangular button?

I can tell you, transparency won't help you, and even if you succeed, your button will remain rectangular in fact. This is easy to checkup with the mouse click. Imagine you make it looking rounded. If you click in the corner, it is not supposed to ignore the click as this is not a button, but in fact it will work like a button click. This is still a rectangular button, nothing else, despite the look (which you still cannot get). Why doing so?

At the same, time the real solution is damn easy. You can have really non-rectangular button, it can behave correctly with mouse and anything else. This is how: create a non-rectangular instance of Region, assign this region to the property System.Windows.Forms.Control.Region. Please see http://msdn.microsoft.com/en-us/library/system.windows.forms.control.region.aspx[^].

You are done!

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900