是否可以用颜色填充所有标签和空格

时间:2016-11-16 21:09:46

标签: c# winforms

我正在尝试用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 :(得分:0)

您可以更改选项卡的BackColor属性:
_tabPage.BackColor = Color.RoyalBlue;

相关问题