2014-08-30 64 views
-1

我正在嘗試更改winform的背景顏色。對於此,我在winform的構造函數中使用ColorDialog。我面臨的問題是我無法設置RGB格式的顏色。 這裏是代碼..使用ColorDialog更改winform的背景顏色

public ChangeAsPerApp() 
    { 
     InitializeComponent(); 

     ColorDialog cddialog = new ColorDialog(); 

     if (true) { 

      //How to set the color here either in RGB or 
      //Some predefined colors or others options available here 

      //I am trying like this but not able to set color 
      this.BackColor = cddialog.Color; 

     } 
    } 

請幫我...請幫我設定RGB格式的顏色。 謝謝

+0

'ColorDialog.CustomColors'屬性是你後是什麼? – 2014-08-30 10:44:58

+0

@SriramSakthivel如何設置RGB顏色到它..? – 2014-08-30 10:47:36

+0

你如何獲得顏色數據?你從哪裏得到它的? – 2014-08-30 10:48:24

回答

0

試試這個:

public ChangeAsPerApp() 
{ 
    InitializeComponent(); 

    if (true) { 
     Color Warn1Color = Color.FromArgb(255, 0, 0);//default colour 
     this.BackColor = Warn1Color;; 

    } 
} 

來源:C# - using ColorDialog across forms