且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用C#Winforms按钮的PNG图像

更新时间:2023-12-05 17:37:46

我也没有得到.我的意思是这个问题.如果您需要按钮仅占据必需"区域,那么它与透明度的关系如何.您是否只想要一个非矩形按钮?

我可以告诉你,透明度不会帮助您,即使您成功了,按钮实际上也会保持矩形.单击鼠标即可轻松进行检查.想象一下,您使它看起来很圆.如果单击角落,则不应忽略该单击,因为这不是按钮,但实际上它将像单击按钮一样工作.尽管外观(您仍然无法看到),但这仍然是矩形按钮.为什么这样做?

同时,真正的解决方案是该死的简单. 您可以拥有真正的非矩形按钮,它可以在鼠标和其他任何东西上正常运行.方法如下:创建Region的非矩形实例,将此区域分配给属性System.Windows.Forms.Control.Region.请参阅 http://msdn.microsoft.com/en-us/library/system.windows.forms.control.region.aspx [
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