tabcontrol改变颜色 [英] tabcontrol changing colour

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

问题描述

Tabcontrol更改属性

Tabcontrol changing properties

private void tabControl1_DrawItem(object sender, 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();
}
        }



此行中出现错误


Error is comming in this line

//TabFont = new Font (e.Font, FontStyle.Italic FontStyle.Bold);

推荐答案

不要说你只是在FontStyle.Italic和FontStyle.Bold之间省略了管道(或),并没有发现它......



也许告诉我们这是什么错误?
Don't say you just left out the pipe (or) in between FontStyle.Italic and FontStyle.Bold, and didn't spot it...

Maybe tell us what is the error?


这篇关于tabcontrol改变颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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