Inorder to change background color of tabs,set the TabControl's DrawMode to OwnerDraw, and then handle the DrawItem event to draw.
this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
Font f;
Brush backBrush;
Brush foreBrush;
if(e.Index == this.tabControl1.SelectedIndex)
{
f = new Font(e.Font, FontStyle.Italic | FontStyle.Bold);
backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.Blue, Color.Red, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
foreBrush = Brushes.PowderBlue;
}
else
{
f = e.Font;
backBrush = new SolidBrush(e.BackColor);
foreBrush = new SolidBrush(e.ForeColor);
}
string tabName = this.tabControl1.TabPages[e.Index].Text;
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
e.Graphics.FillRectangle(backBrush, e.Bounds);
Rectangle r = e.Bounds;
r = new Rectangle(r.X, r.Y + 3, r.Width, r.Height - 3);
e.Graphics.DrawString(tabName, f, foreBrush, r, sf);
sf.Dispose();
if(e.Index == this.tabControl1.SelectedIndex)
{
f.Dispose();
backBrush.Dispose();
}
else
{
backBrush.Dispose();
foreBrush.Dispose();
}
}