2016-06-21 33 views
-4

我試圖改變一個按鈕BACKGROUNDCOLOR變化

BtnColo = System.Drawing.ColorTranslator.FromHtml("#48BCB4"); 
btnAdd.BackColor = ColorTranslator.FromHtml("#48BCB4"); 

的BACKGROUNDCOLOR但它的不正常

+1

你的意思是什麼',但它不工作properly'什麼樣的應用是本 –

+0

顏色保持原樣,沒有任何變化 –

+1

它是一個Windows應用程序或WPF應用程序? –

回答

0

這應該更改按鈕的背景顏色爲紅色

yourButtonName.BackColor = Color.Red; 

您需要包含System.Drawing命名空間,因爲Color類屬於該類。像這樣

using System.Drawing; 

而且ofcourse您需要將引用添加到System.Drawing DLL在項目中使用此命名空間和Color類。

enter image description here

Reference from here

+0

先生,但查詢是我有十六進制顏色代碼 –