Winform 中tabcontrol 美化
需要对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 美化的更多相关文章
- C# winform 中 TabControl 动态显示 TabPage
在winform应用中,tabcontrol是一个很好的控件,可以根据需求提供多个选项卡(TabPages),但是有一个问题是当某个项目需要多个选项卡,但是不同的功能要求显示不同的选项卡,其他的非该功 ...
- c# winform中TabControl中给每个选项卡添加不同的图标(图片)
在一个TabControl控件中,有几个选项卡,现在在每个选项卡上显示不同的图标. 1:你要现在form窗体中通过工具箱加入一个imagelist,名字为imagelist1,如下图: 2:然后在里面 ...
- WinForm中TabControl的使用
TabControl和TabPage之间有一个默认颜色的边框,很难去除,需要重写TabControl控件重绘区域 public class FullTabControl : TabControl { ...
- winform中tabControl的标题隐藏
方法一: Apperarance 属性:Faltbuttons SizeMode属性:Fixed 各个TabPage的Text :空 ItemSize : Width=0;Height=1; //He ...
- Winform 自定义TabControl实现浏览器标签
作者:Gavin(daisong.michelangelo@gmail.com) 时间: Nov, 2015 封面图片为Gavin原创,请勿未经允许私自引 最近因为工作需要,要做一个桌面浏览器,和大多 ...
- C# Winform中窗体的美化—— 用IrisSkin轻松实现换肤功能
今天经前辈提醒才知道winform窗体还有美化工具,呵呵,不得不说,孤陋寡闻了.下面总结一下irisskin2的使用步骤和遇到的问题及解决办法. 1.网址:http://www.pc6.com/sof ...
- 控制WinForm中Tab键的跳转
一,需求 在Winform中,默认情况下,按下Tab键,光标会按照我们设定的TabIndex值从小到大进行跳转. 但如果用户要求按下Tab键跳转到特定的控件,这种要求还是很合理的,比如用户只想输入几个 ...
- 转载:WinForm中播放声音的三种方法
转载:WinForm中播放声音的三种方法 金刚 winForm 播放声音 本文是转载的文章.原文出处:http://blog.csdn.net/jijunwu/article/details/4753 ...
- C# Winform 中如何实现音乐播放和视频播放
C# Winform 中如何实现音乐播放和视频播放 namespace WindowsFormsApplication1 { public partial class Form2 : Form { ...
随机推荐
- 从软件project的角度写机器学习3——主要监督学习算法的project性分析
主要机器学习算法的project适用性分析 前段时间AlphaGo跟李世石的大战及相关的深度学习的新闻刷了一遍又一遍的朋友圈.只是这件事情,也仅仅是在机器学习的深度上进一步拓展,而机器学习的广度(也即 ...
- js进阶 14-1 jquery的ajax系列中的load方法的作用是什么
js进阶 14-1 jquery的ajax系列中的load方法的作用是什么 一.总结 一句话总结:jQuery load()方法作用是从服务器加载数据,是一个简单但强大的AJAX方法. 1.load函 ...
- amazeui学习笔记--css(常用组件15)--CSS动画Animation
amazeui学习笔记--css(常用组件15)--CSS动画Animation 一.总结 1.css3动画封装:CSS3 动画封装,浏览器需支持 CSS3 动画. Class 描述 .am-anim ...
- Codeforces Beta Round #24 D. Broken robot (打表找规律)
题目链接: 点击我打开链接 题目大意: 给你 \(n,j\),再给出 \(m[0]\) 的坐标和\(a[0]-a[n-1]\) 的坐标. 让你输出 \(m[j]\) 的坐标,其中 \(m[i]\) 和 ...
- Java核心技术 卷Ⅰ 基础知识(5)
第11章 异常.断言.日志和调试 处理错误 异常分类 声明已检查异常 如何抛出异常 创建异常类 捕获异常 捕获多个异常 再次抛出异常与异常链 finally子句 带资源的try语句 分析堆栈跟踪元素 ...
- Altium Designer导入pcb原件之后都是绿的
- [React Intl] Install and Configure the Entry Point of react-intl
We’ll install react-intl, then add it to the mounting point of our React app. Then, we’ll use react- ...
- Redis笔记---set
1.redis set的介绍 集合中的数据是不重复且没有顺序,集合类型和列表类型的对比. 集合类型:存储的是的是最多2的32次方减一个字符串,数据是没有顺序的,但是数据是唯一的 列表类型:最多存储内容 ...
- java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: student is not mapped
Spring 5.0 +Jpa,使用@Query实现 自定义查询报错: java.lang.IllegalArgumentException: org.hibernate.hql.internal.a ...
- 【57.97%】【codeforces Round #380A】Interview with Oleg
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...