需要对tabcontrol按照美工出的图进行美化

对tabpage页进行标题设置,首先对整个tabcontrol的DrawMode设置为OwnerDrawFixed,由于需要对标题宽度有要求,设置sizemode为fixed,可以对itemsize调整,设置标题的宽和高,然后进行写事件就能实现

 private void tb_DrawItem(object sender, DrawItemEventArgs e)
{
StringFormat sf = new StringFormat(); #region 头背景
sf.LineAlignment = StringAlignment.Center;
sf.Alignment = StringAlignment.Center;
Rectangle rec = tb.ClientRectangle;
//获取背景图片,我的背景图片在项目资源文件中。
Image backImage = Properties.Resources.pop_tab1_2;
e.Graphics.DrawImage(backImage, , , tb.Width, tb.ItemSize.Height + );
#endregion
#region 设置选择的标签的背景
if (e.Index == tb.SelectedIndex)
e.Graphics.DrawImage(Properties.Resources.pop_tab1_1, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
else
e.Graphics.DrawImage(Properties.Resources.pop_tab1_2, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawString(((TabControl)sender).TabPages[e.Index].Text,
System.Windows.Forms.SystemInformation.MenuFont, new SolidBrush(Color.Black), e.Bounds, sf);
#endregion
#region 重写标签名
ColorConverter colorConverter = new ColorConverter();
Color cwhite = (Color)colorConverter.ConvertFromString("#2178ba");
SolidBrush white = new SolidBrush(cwhite);
Rectangle rect0 = tb.GetTabRect();
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
       e.Graphics.DrawString("申请单号", new Font("微软雅黑", 12), white, rect0, stringFormat);
           #endregion
}

Winform 中tabcontrol 美化的更多相关文章

  1. C# winform 中 TabControl 动态显示 TabPage

    在winform应用中,tabcontrol是一个很好的控件,可以根据需求提供多个选项卡(TabPages),但是有一个问题是当某个项目需要多个选项卡,但是不同的功能要求显示不同的选项卡,其他的非该功 ...

  2. c# winform中TabControl中给每个选项卡添加不同的图标(图片)

    在一个TabControl控件中,有几个选项卡,现在在每个选项卡上显示不同的图标. 1:你要现在form窗体中通过工具箱加入一个imagelist,名字为imagelist1,如下图: 2:然后在里面 ...

  3. WinForm中TabControl的使用

    TabControl和TabPage之间有一个默认颜色的边框,很难去除,需要重写TabControl控件重绘区域 public class FullTabControl : TabControl { ...

  4. winform中tabControl的标题隐藏

    方法一: Apperarance 属性:Faltbuttons SizeMode属性:Fixed 各个TabPage的Text :空 ItemSize : Width=0;Height=1; //He ...

  5. Winform 自定义TabControl实现浏览器标签

    作者:Gavin(daisong.michelangelo@gmail.com) 时间: Nov, 2015 封面图片为Gavin原创,请勿未经允许私自引 最近因为工作需要,要做一个桌面浏览器,和大多 ...

  6. C# Winform中窗体的美化—— 用IrisSkin轻松实现换肤功能

    今天经前辈提醒才知道winform窗体还有美化工具,呵呵,不得不说,孤陋寡闻了.下面总结一下irisskin2的使用步骤和遇到的问题及解决办法. 1.网址:http://www.pc6.com/sof ...

  7. 控制WinForm中Tab键的跳转

    一,需求 在Winform中,默认情况下,按下Tab键,光标会按照我们设定的TabIndex值从小到大进行跳转. 但如果用户要求按下Tab键跳转到特定的控件,这种要求还是很合理的,比如用户只想输入几个 ...

  8. 转载:WinForm中播放声音的三种方法

    转载:WinForm中播放声音的三种方法 金刚 winForm 播放声音 本文是转载的文章.原文出处:http://blog.csdn.net/jijunwu/article/details/4753 ...

  9. C# Winform 中如何实现音乐播放和视频播放

    C#  Winform 中如何实现音乐播放和视频播放 namespace WindowsFormsApplication1 { public partial class Form2 : Form { ...

随机推荐

  1. LayUI-Table表格渲染

    记项目中又一表格使用方法,项目首选是使用BootstrapTable的,但是经过多番查证与调试,始终没有把固定列的功能调试成功,找到的成功的例子原样照搬都不行,文件引入也都没有问题,实在搞不懂了,如果 ...

  2. python 序列排序 排序后返回相应的索引

    https://blog.csdn.net/longwei92/article/details/83098289 https://blog.csdn.net/u013731339/article/de ...

  3. (转)c运行库、c标准库、windows API的区别和联系

    C运行时库函数C运行时库函数是指C语言本身支持的一些基本函数,通常是汇编直接实现的.  API函数API函数是操作系统为方便用户设计应用程序而提供的实现特定功能的函数,API函数也是C语言的函数实现的 ...

  4. android 5.x system.img 大于2G导致编译otapackage时报错怎样处理

    当system分区预制过多apk时假设img size超过2G 在make otapackage时会报例如以下错误  zipfile.LargeZipFile: Zipfile size would ...

  5. Debian 上创建新的用户

    Debian 上创建新的用户 使用Gnome的窗口界面创建 使用Linux的命令创建 添加用户: useradd -d /home/your_username -m your_username 添加密 ...

  6. PDO中获取结果集

    fetch()方法 fetch()方法用于获取结果集的下一行.语法例如以下: mixed PDOStatement::fetch([int fetch_style][,int cursor_orien ...

  7. [AngularFire 2 ] Hello World - How To Write your First Query using AngularFire 2 List Observables ?

    In this lesson we are going to use AngularFire 2 for the first time. We are going to configure the A ...

  8. 4、linux开发中常用指令

    1.cat /proc/device 可以查看各个全部字符设备和块设备,在register_chrdev中设置的名字在打印出来的信息中可以看到:2.top 可以看各个应用程序占用CPU量及PID等信息 ...

  9. VC使用ADO连接远程oracle数据库

    _ConnectionPtr pConn;//连接对像 _RecordsetPtr pRect;//记录集对象 _CommandPtr  pCmd;//命令对象 pRect.CreateInstanc ...

  10. 教你写Http框架(二)——三个样例带你深入理解AsyncTask

    这个标题大家不要奇怪,扯Http框架怎么扯到AsyncTask去了,有两个原因:首先是Http框架除了核心http理论外.其技术实现核心也是线程池 + 模板 + handler,而AsyncTask又 ...