2016-11-16 69 views
0

我試圖填寫標籤和背景標籤,其中一個RGB顏色,像這樣是否有可能填補所有選項空間與色彩

Example

我想做的事情我的標籤就像一個在右邊,它是一種顏色,

下面的代碼,我有:

// Get the item from the collection. 
TabPage _tabPage = tabControl1.TabPages[e.Index]; 

// Get the real bounds for the tab rectangle. 
Rectangle _tabBounds = tabControl1.GetTabRect(e.Index); 

if (e.State == DrawItemState.Selected) 
{ 

    // Draw a different background color, and don't paint a focus rectangle. 
    _textBrush = new SolidBrush(Color.FromArgb(255, 66,78,90)); 
    g.FillRectangle(Brushes.Gray, e.Bounds); 
} 
else 
{ 
    _textBrush = new System.Drawing.SolidBrush(e.ForeColor); 
    e.DrawBackground(); 
} 

我已經設置的標籤來繪製模式,我如何能實現我的目標是什麼?

+1

爲什麼畫自己而不是簡單地設置背景顏色? –

+0

我沒有選擇設置背景顏色 – RadomRadom

+2

如果您想完全控制UI,不推薦使用WinForms。你應該使用WPF來代替。 – Dai

回答

0

您可以更改選項卡的BackColor屬性:
_tabPage.BackColor = Color.RoyalBlue;

相關問題