c# TabControl怎么改变选中页的头部标签颜色? 如题:c#中 TabControl怎么改变选中的标签的头部颜色? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c93c.aspx#q1094q TabControl这个东西,没法改变头部的颜色,只有自己继承,写控件了,代码不少。你也可以用dotNetBar2,这个集成的工具箱,网上搜一下,加到自己的工具箱中就好了,那里面有改好的TabControl using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace testTabFlash{ public partial class Form1 : Form { public Form1() { InitializeComponent(); this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed; this.tabControl1.DrawItem += new DrawItemEventHandler(this.tabControl1_DrawItem); } private void Form1_Load(object sender, EventArgs e) { } private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { Font fntTab; Brush bshBack; Brush bshFore;if (e.Index == this.tabControl1.SelectedIndex) //当前Tab页的样式 { fntTab = new Font(e.Font, FontStyle.Bold); bshBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, SystemColors.Control, SystemColors.Control, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal); bshFore = Brushes.Black; } else //其余Tab页的样式 { fntTab = e.Font; bshBack = new SolidBrush(Color.Blue); bshFore = new SolidBrush(Color.Black); } //画样式 string tabName = this.tabControl1.TabPages[e.Index].Text; StringFormat sftTab = new StringFormat(); e.Graphics.FillRectangle(bshBack, e.Bounds); Rectangle recTab = e.Bounds; recTab = new Rectangle(recTab.X, recTab.Y + 4, recTab.Width, recTab.Height - 4); e.Graphics.DrawString(tabName, fntTab, bshFore, recTab, sftTab); } }} 在网上搜索这个控件[FlatTabControl]是别人写的一个控件[FlatTabControl.dll] 可以修改标签的颜色 C# winform内容器的字体 网站+sql2000 请教多态性 Winform窗体的MouseDown和MouseDoubleClick事件 有用过Graphics Server.Net控件的么,有个坐标的问题 如何對Sql server表中的密碼字段加密 为什么要用“实现类 继承 抽象类 继承 接口”的模式呀,谢谢。 .net安装制作中桌面快捷方式的问题 请教:C#的联合怎么声明,如何使用? 学习c#语言需要精通c语言吗 弱弱的问一句,大家平时用反射、委托等多不多啊! C#如何得到谁访问过我的电脑的IP
那里面有改好的TabControl
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace testTabFlash
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.tabControl1.DrawItem += new DrawItemEventHandler(this.tabControl1_DrawItem); } private void Form1_Load(object sender, EventArgs e)
{ } private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
Font fntTab;
Brush bshBack;
Brush bshFore;
if (e.Index == this.tabControl1.SelectedIndex) //当前Tab页的样式
{
fntTab = new Font(e.Font, FontStyle.Bold);
bshBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, SystemColors.Control, SystemColors.Control, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal);
bshFore = Brushes.Black;
}
else //其余Tab页的样式
{
fntTab = e.Font;
bshBack = new SolidBrush(Color.Blue);
bshFore = new SolidBrush(Color.Black);
}
//画样式
string tabName = this.tabControl1.TabPages[e.Index].Text;
StringFormat sftTab = new StringFormat();
e.Graphics.FillRectangle(bshBack, e.Bounds);
Rectangle recTab = e.Bounds;
recTab = new Rectangle(recTab.X, recTab.Y + 4, recTab.Width, recTab.Height - 4);
e.Graphics.DrawString(tabName, fntTab, bshFore, recTab, sftTab);
}
}
}