This is my code bellow:-
This is a code of coloring Tab from my window application. And I want the exact color Mercury (E6E6E6 or 230, 230, 230) of tabs . I'm unable to do that. Help me out ASAP. Also check the attachment and let me know if you can change the back color also to Tab color.
Code:
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.Bold | FontStyle.Regular); backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.Gainsboro, Color.Gainsboro, System.Drawing.Drawing2D.LinearGradientMode.Vertical); foreBrush = Brushes.Black; } 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(); } }
Comment