2014-12-23 39 views
1

我已經創建了一個按鈕和應用圖像(.png具有透明背景)。
enter image description here
我的按鈕背景設置爲透明,但您可以看到背景顏色仍然存在。
我該如何做這個工作?如何使按鈕背景透明?

+0

您是使用WinForms,WPF還是其他? – Zairja

+0

@Zairja我正在使用 WinForms,對不起會添加標籤 – Hoh

回答

4

給這個鏡頭。

'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 
+0

這解決了我所有的問題。非常感謝你。 – Hoh

+0

這也可以通過屬性表完成。 +1給予我正在尋找的物業。 – phrebh

1

,我想出了另一種選擇是撥打:

SetStyle(ControlStyles.SupportsTransparentBackColor, True)

時創建的形式(例如在構造函數中InitializeComponent()後)。該按鈕的BackColor也被設置爲透明(這可以在代碼後面或屬性中完成)。

+0

這也可能是一個解決方案,但只是使所有按鈕背景的形式都是透明的。無論如何 – Hoh