Click here to Skip to main content
11,496,146 members (1,589 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
I have sent an app to my colleagues and they have win7, stlye in win is set to aero stlyle. They see all tabpage-s white even though I see in gray, color is by default "Control".
If i try this code:
    tabControl3.TabPages[0].BackColor = Color.Green;
i get the tabpage green, but the "tab" above (where the text is for the tabpage) is stil grey.

Hot to make the whole tabcontrol in diferent color. In Properties window you can only change color to a tabpage but not to a whole tabcontrol.
Posted 2-Dec-12 13:08pm
Sergey Alexandrovich Kryukov at 2-Dec-12 20:37pm
What's wrong with tabControl.BackColor?
And do yourself a favor: get rid of all names like "tabControl13". Never use auto-generated names -- they violate (good) Microsoft naming conventions/recommendations. Always rename them all to give them semantic names.
Simon_Whale at 3-Dec-12 4:11am
That changes the color of the tabpage but not the actual tab which the OP is after, I know that this is a custom draw event on the control
Sergey Alexandrovich Kryukov at 3-Dec-12 5:24am
How about changing both? Each tab — dynamically...
Simon_Whale at 3-Dec-12 5:33am
you have to override the drawitem event in the tabcontrol to deal with the actual tab and do the changing of the colour of the tabpage with the usual tabpage.backcolor = etc.
Sergey Alexandrovich Kryukov at 3-Dec-12 12:46pm
Well, agree...
I would have a read of this Codeproject article is shows how to change the colour of the tabs.

A .NET Flat TabControl (CustomDraw)[^]
Sergey Alexandrovich Kryukov at 3-Dec-12 12:47pm
Pretty good response, a 5.
Simon_Whale at 3-Dec-12 14:37pm
Thanks SA
I'm agreed with Mr SA.. Don't use this kind of names for controls..
and your answer is here:
private void ChangeTabColor(DrawItemEventArgs e)
Font TabFont;
Brush BackBrush = new SolidBrush(Color.Green); //Set background color
Brush ForeBrush = new SolidBrush(Color.Yellow);//Set foreground color
if (e.Index == this.tabControl1.SelectedIndex)
TabFont = new Font(e.Font, FontStyle.Italic FontStyle.Bold);
TabFont = e.Font;
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, TabFont, ForeBrush, r, sf);
//Dispose objects
if (e.Index == this.tabControl1.SelectedIndex)
and here all about TabControl is given :[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 RyanDev 230
2 CHill60 208
3 Sascha Lefèvre 195
4 Sergey Alexandrovich Kryukov 124
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100