Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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
Comments
Sergey Alexandrovich Kryukov 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 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 3-Dec-12 5:24am    
How about changing both? Each tab — dynamically...
—SA
Simon_Whale 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 3-Dec-12 12:46pm    
Well, agree...
--SA

I would have a read of this Codeproject article is shows how to change the colour of the tabs.

A .NET Flat TabControl (CustomDraw)[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Dec-12 12:47pm    
Pretty good response, a 5.
--SA
Simon_Whale 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);
}
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/[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900