c# TabControl怎么改变选中页的头部标签颜色?

sshh00 2010-07-08 08:05:44
如题:
c#中 TabControl怎么改变选中的标签的头部颜色?
...全文
2858 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
xsmmk 2012-04-30
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
C# code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace testTabFlash
{
……
[/Quote]

学习了
sshh00 2010-07-09
  • 打赏
  • 举报
回复
但是我的系统上已经有很多东西了,换控件会很麻烦的。
如果重新绘制的话,系统生成的那些东西怎么办?并且使套了皮肤,也还是有问题。。。
wxm3630478 2010-07-09
  • 打赏
  • 举报
回复


在网上搜索这个控件[FlatTabControl]

是别人写的一个控件[FlatTabControl.dll] 可以修改标签的颜色
klml884228788 2010-07-09
  • 打赏
  • 举报
回复
UP ..................
修改一下昵称 2010-07-09
  • 打赏
  • 举报
回复 4
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);
}
}
}
ioiott 2010-07-09
  • 打赏
  • 举报
回复
TabControl这个东西,没法改变头部的颜色,只有自己继承,写控件了,代码不少。

你也可以用dotNetBar2,这个集成的工具箱,网上搜一下,加到自己的工具箱中就好了,
那里面有改好的TabControl
风之影子 2010-07-09
  • 打赏
  • 举报
回复
重写控件的着色事件方法。
blue601 2010-07-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jianuman 的回复:]
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c93c.aspx#q1094q
[/Quote]
全是英文哈

111,100

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧