[c#] tabcontrol,将颜色更改为整个tabcontrol [英] [c#] tabcontrol, change the color to whole tabcontrol

查看:180
本文介绍了[c#] tabcontrol,将颜色更改为整个tabcontrol的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经向我的同事们发送了一个应用程序,他们已经取得了胜利7,胜利的成果将被设置为aero stlyle。他们看到所有tabpage-s白色,即使我看到灰色,默认颜色为Control。

如果我尝试这段代码:

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;



我将标签页设为绿色,但上面的标签(文字用于标签页)是灰色的。



热门使用不同颜色制作整个tabcontrol。在属性窗口中,您只能将颜色更改为标签页而不能更改为整个tabcontrol。


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.

推荐答案

我将阅读此Codeproject文章,其中显示了如何更改选项卡的颜色。



.NET Flat TabControl(CustomDraw) [ ^ ]
I would have a read of this Codeproject article is shows how to change the colour of the tabs.

A .NET Flat TabControl (CustomDraw)[^]


我同意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();
}
}



这里给出了关于TabControl的所有内容:

http://www.c-sharpcorner.com/uploadfile/mahesh/c-sharp-tabcontrol/ [ ^ ]


这篇关于[c#] tabcontrol,将颜色更改为整个tabcontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆