问题
I have created one button and applied image (.png with transparent background) on it.
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