Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
Comments
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.
--SA
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...
—SA
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 = color.black etc.
Sergey Alexandrovich Kryukov at 3-Dec-12 12:46pm
   
Well, agree...
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I would have a read of this Codeproject article is shows how to change the colour of the tabs.
 
A .NET Flat TabControl (CustomDraw)[^]
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 3-Dec-12 12:47pm
   
Pretty good response, a 5.
--SA
Simon_Whale at 3-Dec-12 14:37pm
   
Thanks SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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);
}
else
{
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
sf.Dispose();
if (e.Index == this.tabControl1.SelectedIndex)
{
TabFont.Dispose();
BackBrush.Dispose();
}
else
{
BackBrush.Dispose();
ForeBrush.Dispose();
}
}
and here all about TabControl is given :
http://www.c-sharpcorner.com/uploadfile/mahesh/c-sharp-tabcontrol/[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,800
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2014
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