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
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.
//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.
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
What Regular Expression Would I Use to Remove Everything After the Second Backslash
How to Split Json String in C# and Store in Separate Variables
How to Determine If .Net Core Is Installed
Select Multiple Fields from List in Linq
How to Redirect to Login Page If Session Is Not Available in MVC
Browser Back Button Navigates to Login Page When User Is Still Logged In
Unicode Characters Replace from String Using C#
Web-Api Post Body Object Always Null
How to Remove Illegal Characters from Path and Filenames
How to Disable Cursor in Textbox
Sorting a Collection Containing Strings And/Or Numbers
Asp.Net Core Get Json Array Using Iconfiguration
How to Display Values Only Upto 2 Decimal Places
How to Use Telegram API in C# to Send a Message
How to Store List of Data from Database to Arraylist or List in C#