How to Change Background Colour of Tab Control in Winforms

How to change the background color of unused space tab in C# winforms?

I think the only way to give that space a color is to override the OnPaintBackground method of the window, so just paste this on your form (window)

you must also change the Appearance Property to "Normal"

private void Form1_Load(object sender, EventArgs e)
{

}

protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
Rectangle lasttabrect = tabControl1.GetTabRect(tabControl1.TabPages.Count - 1);
RectangleF emptyspacerect = new RectangleF(
lasttabrect.X + lasttabrect.Width + tabControl1.Left,
tabControl1.Top + lasttabrect.Y,
tabControl1.Width - (lasttabrect.X + lasttabrect.Width),
lasttabrect.Height);

Brush b = Brushes.BlueViolet; // the color you want
e.Graphics.FillRectangle(b, emptyspacerect );
}

for me it's working perfectly

enter image description here

Background color for Tabcontrol in c# windows application

I would check out this codeproject example. It shows how to color the tabs as well as the entire selected control.

In your example, you can change the BackBrush to a Solid brush and add this before the sf.Dispose line:

TaskBarRef.tabControl1.TabPages[e.Index].BackColor = BackBrush.Color;

TabControl Custom Tab Bar Background Color

I added the following code to my SettingsTabControl_DrawItem method, which fixes this specific issue. I still have a border color issue, but I guess I can live with that.

enter image description here

        //draw rectangle behind the tabs
Rectangle lastTabRect = SettingsTabControl.GetTabRect( SettingsTabControl.TabPages.Count - 1 );
Rectangle background = new Rectangle();
background.Location = new Point( lastTabRect.Right, 0 );

//pad the rectangle to cover the 1 pixel line between the top of the tabpage and the start of the tabs
background.Size = new Size( SettingsTabControl.Right - background.Left, lastTabRect.Height + 1 );

using (SolidBrush b = new SolidBrush( Colors.Get( Item.BorderBackground ) ))
{
e.Graphics.FillRectangle( b, background );
}

From here.

Change the background of TabControl Header in C# Winform

I solved it myself.
I used this control http://dotnetrix.co.uk/controls.htm
It has a TabControl2 that supports the transparent background for TabControl.
Now it looks pretty good.

enter image description here

How to change Tab Control Background Color (VB.NET)

There is no property to do this. However it is possible by using something like this

http://dotnetrix.co.uk/tabcontrol.htm

All controls on this site are freely available under MIT license.



Related Topics



Leave a reply



Submit