需要对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. nuxt配置sass

    没有比这更简单的了 只需要安装 node-sass sass-loader 就可以了 npm i node-sass sass-loader -D 然后就可以直接使用了: <style lang ...

  2. 【例题 7-3 UVA - 10976】Fractions Again?!

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] x>=y => \(\frac{1}{x}<=\frac{1}{y}\) => \(\frac{1}{x}= ...

  3. java set转list,数组与list的转换

    读zookeeper的源码(zookeeper.java)时发现的,平时没有怎么注意: private final ZKWatchManager watchManager; List<Strin ...

  4. socket长连接的维持

    长连接的维持,是要客户端程序,定时向服务端程序,发送一个维持连接包的.如果,长时间未发送维持连接包,服务端程序将断开连接. 客户端:通过持有Client对象,可以随时(使用sendObject方法)发 ...

  5. ThreadPoolExecutor – Java Thread Pool Example(如何使用Executor框架创建一个线程池)

    Java thread pool manages the pool of worker threads, it contains a queue that keeps tasks waiting to ...

  6. OVS中对于用户层和datapath层的多个通道利用epoll进行控制

    这里先临时记录下代码流程,有待完好. static int construct(struct ofproto *ofproto_) { struct ofproto_dpif *ofproto = o ...

  7. Windows服务安装命令:

    sc create YY.SmsPlatform.RemoteDataCenter binPath= "E:\YY.SmsPlatform\YY.SmsPlatform.RemoteData ...

  8. Ansible 管理服务和软件

    [root@Ansible ~]# ansible RAC -m yum -a 'name=iscsi-initiator-utils state=installed' RAC_Node1 | suc ...

  9. [RxJS] AsyncSubject: representing a computation that yields a final value

    This lesson will teach you about AsyncSubject, another type of Subject with some replaying logic ins ...

  10. mha && 脚本拉起

    ip分布:  vip 192.168.238.222 mha_manager 192.168.238.131 监控服务器 master 192.168.238.128 主库GTID复制模式 slave ...