private void tabClientFolder_DrawItem(object sender, DrawItemEventArgs e)
{
try
{
Font f;
Brush backBrush;
Brush foreBrush;
if (e.Index == this.tabControl1.SelectedIndex)
{
f = new Font(e.Font, FontStyle.Bold);
backBrush = new System.Drawing.SolidBrush(Color.FromArgb(255, 181, 199, 181));
foreBrush = Brushes.Black;
} else
{
f = e.Font;
backBrush = new System.Drawing.SolidBrush(Color.FromArgb(255, 181, 199, 181));
foreBrush = new SolidBrush(e.ForeColor);
}
string tabName = this.tabControl1.TabPages[e.Index].Text;
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Near;
e.Graphics.FillRectangle(backBrush, e.Bounds);
Rectangle r = e.Bounds;
r = new Rectangle(r.X, r.Y + 5, r.Width, r.Height - 5);
e.Graphics.DrawString(tabName, f, foreBrush, r, sf);
sf.Dispose();
if (e.Index == this.tabClientFolder.SelectedIndex)
{
f.Dispose();
backBrush.Dispose();
} else
{
backBrush.Dispose();
foreBrush.Dispose();
}
}This code snippet is for Colour the Tab Header of Tab Control using C#.
