How to make button background transparent?

本秂侑毒 提交于 2021-02-08 03:11:17

问题


I have created one button and applied image (.png with transparent background) on it.
enter image description here
My button background is set on transparent but as you can see the background color is still there.
How can I make this work as it should?


回答1:


Give this a shot.

'Making Existing Button Transparent
btnKasa.FlatStyle = Windows.Forms.FlatStyle.Flat
btnKasa.FlatAppearance.BorderSize = 0
btnKasa.FlatAppearance.MouseDownBackColor = Color.Transparent
btnKasa.FlatAppearance.MouseOverBackColor = Color.Transparent
btnKasa.BackColor = Color.Transparent



回答2:


Another option that I came up with is to call:

SetStyle(ControlStyles.SupportsTransparentBackColor, True)

when the form is created (e.g. in the constructor after InitializeComponent()). The button's BackColor is set to Transparent, as well (this can be done in code behind or in the properties).



来源:https://stackoverflow.com/questions/27628216/how-to-make-button-background-transparent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!