-
大小: 63KB文件类型: .zip金币: 2下载: 1 次发布日期: 2021-06-08
- 语言: C#
- 标签: tabcontrol
资源简介
强迫症需要没合适的插件,来满足需求,无奈自己重写Tabcontrol,高仿360浏览器选项卡,主要适用于浏览器,容器类控件
基于WinForm开发,添加,删除按钮,去掉了多余的页边距,和讨厌的虚线框,风格整体扁平化,无闪烁,资源占用小
界面看博客:https://blog.csdn.net/CFY530/article/details/81784826
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace WindowsFormsApp1
{
public class MordernTabcontrol : TabControl
{
const int CLOSE_SIZE = 16;
const int ADD_SIZE = 16;
public readonly Bitmap Add = Properties.Resources.Add;//添加按钮资源获取
public readonly Bitmap Close = Properties.Resources.Close;//关闭按钮资源获取
public MordernTabcontrol()
:base()
{
Setstyles();
this.SizeMode = TabSizeMode.Fixed;
this.Dock = Dockstyle.Fill;
this.Font = new System.Drawing.Font(“微软雅黑“ 9F);
this.ItemSize = new System.Drawing.Size(232 30);
}
private void Setstyles()
{
base.Setstyle(
Controlstyles.DoubleBuffer |
Controlstyles.UserPaint |
Controlstyles.OptimizedDoubleBuffer |
Controlstyles.AllPaintingInWmPaint |
Controlstyles.ResizeRedraw |
Controlstyles.SupportsTransparentBackColor true);
base.Updatestyles();
}
///
/// 解决系统TabControl多余边距问题
///
public override Rectangle DisplayRectangle
{
get
{
Rectangle rect = base.DisplayRectangle;
return new Rectangle(rect.Left - 3 rect.Top-1 rect.Width + 8 rect.Height + 8);
}
}
protected override void onselecting(TabControlCancelEventArgs e)
{
if (e.TabPageIndex == this.TabPages.Count - 1)//拦截添加选项卡事件
e.Cancel = true;
}
protected override void OnPaint(PaintEventArgs e)
{
Rectangle rect = this.ClientRectangle; //获取tabcontrol背景区域
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;//画图质量
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
using (BufferedGraphics bufferedGraphics = BufferedGraphicsManager.Current.Allocate(e.Graphics rect))//创建缓冲 Graphics对象,区域
{
bufferedGraphics.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(222235252)) rect);//填充背景
for (int index = 0; index < this.TabCount; index++)
{
DrawTabPage(bufferedGraphics.Graphics this.GetTabRect(index)index);
}
bufferedGraphics.Render(e.Graphics); //获取缓冲 Graphics对象,区域
}
base.OnPaint(e);
}
private void DrawTabPage(Graphics graphics Rectangle rectangleint index)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-08-18 00:15 WindowsFormsApp1\
文件 189 2018-08-08 01:14 WindowsFormsApp1\App.config
文件 10373 2018-08-18 00:14 WindowsFormsApp1\MordernTabcontrol.cs
文件 531 2018-08-12 18:03 WindowsFormsApp1\Program.cs
目录 0 2018-08-18 00:11 WindowsFormsApp1\Properties\
文件 1330 2018-08-08 01:14 WindowsFormsApp1\Properties\AssemblyInfo.cs
文件 3605 2018-08-15 23:24 WindowsFormsApp1\Properties\Resources.Designer.cs
文件 6433 2018-08-15 23:24 WindowsFormsApp1\Properties\Resources.resx
文件 1103 2018-08-08 01:14 WindowsFormsApp1\Properties\Settings.Designer.cs
文件 249 2018-08-08 01:14 WindowsFormsApp1\Properties\Settings.settings
目录 0 2018-08-18 00:11 WindowsFormsApp1\Resources\
文件 112 2018-08-08 22:42 WindowsFormsApp1\Resources\Add.png
文件 140 2018-08-08 22:42 WindowsFormsApp1\Resources\Close.png
文件 4696 2018-08-18 00:15 WindowsFormsApp1\TestForm.Designer.cs
文件 806 2018-08-18 00:15 WindowsFormsApp1\TestForm.cs
文件 9721 2018-08-18 00:15 WindowsFormsApp1\TestForm.resx
文件 4014 2018-08-15 23:32 WindowsFormsApp1\WindowsFormsApp1.csproj
文件 3070 2018-08-09 17:19 WindowsFormsApp1\app.manifest
目录 0 2018-08-18 00:11 WindowsFormsApp1\bin\
目录 0 2018-08-18 00:11 WindowsFormsApp1\bin\Debug\
文件 20992 2018-08-18 00:15 WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe
文件 189 2018-08-08 01:14 WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe.config
文件 28160 2018-08-18 00:15 WindowsFormsApp1\bin\Debug\WindowsFormsApp1.pdb
目录 0 2018-08-18 00:17 WindowsFormsApp1\bin\Release\
目录 0 2018-08-18 00:11 WindowsFormsApp1\obj\
目录 0 2018-08-18 00:15 WindowsFormsApp1\obj\Debug\
文件 29227 2018-08-15 23:40 WindowsFormsApp1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7335 2018-08-15 23:24 WindowsFormsApp1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2018-08-18 00:11 WindowsFormsApp1\obj\Debug\TempPE\
文件 3584 2018-08-15 23:24 WindowsFormsApp1\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 0 2018-08-08 01:14 WindowsFormsApp1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
............此处省略11个文件信息
相关资源
- WPF圆润的TabItem和TabControl
- 控件重绘 C# WinForm控件美化扩展系列之
- TabControl重绘添加关闭按钮与Treeview导
- 很漂亮的自定义TabControl控件
- winform tabcontrol 美化控件
- WPF模拟迅雷TabControl界面
- .net TabControl 多种风格的自绘
- winform用tabcontrol切换mdi子窗口及为ta
-
Wpf下fr
ame、MDI、TabControl简单应用 - VB.NET 仿Edge风格的TabControl控件
- c# 自定义控件 - 重绘控件 - TabControl
- wpf美化tabcontroll并且支持gif动画
- tabcontrol动态生成选项卡,并添加窗体
- WPF TabControl完美样式在下方显示+完美
- C#TabControl控件实现窗体的整合与切换
- C#TabControl重写(添加关闭与添加按钮
- TabControl C#编写的TabControl控件
- c#_tabControl_Form简单实现
- TabControl模板
- WPF Prism 依赖注入实现可关闭的TabCon
- 实现VisualStudio编辑器的TabControl
- WPF漂亮带关闭的TabControl
评论
共有 条评论