How to change the background color of a tab control in Winforms?

Is there a way to change the background color of the tab control in winforms so that it does not have a white border around it?

I tried several different ways, but all of them lead to displaying the same white border.

+6
c # winforms
source share
4 answers

The only way to achieve this is to make the tabcontrol itself.

Here is an example on CodeProject.com

+6
source share

I can only think about changing the Appearance property to buttons

Appearance of MSDN TabControl

+2
source share

TabControl has very poor support for customization. I used this custom tab control with good success. The code is pretty useful if you want to change the look like me.

+1
source share

Even simpler (IMO): add a paint handler to TabPage (not to the top level of TabControl, but TabPage inside it, and then color the background rectangle to the desired color.

  • Either in the designer or manually, add a Paint event handler to TabPage:

     Page1.Paint += tabpage_Paint; // custom paint event so we get the backcolor we want 
  • In the drawing method, draw a rectangle of the page of the desired color (in my case, I want it to conform to the BackColor standard):

     // force the tab background to the current BackColor private void tabpage_Paint(object sender, PaintEventArgs e) { SolidBrush fillBrush = new SolidBrush(BackColor); e.Graphics.FillRectangle(fillBrush, e.ClipRectangle); } 
+1
source share

All Articles