最近项目需要自定义tabControl控件颜色,而默认这个控件是不支持自定义标签颜色的,于是想办法实现了这个功能,效果如下图所示:
直接上代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CustomTabControl
{
public partial class Form1 : Form
{
private TabControl tabControl;
private TabPage tabPage1;
private TabPage tabPage2;
private TabPage tabPage3;
public Form1()
{
// 初始化控件
tabControl = new TabControl();
tabPage1 = new TabPage("红");
tabPage2 = new TabPage("绿");
tabPage3 = new TabPage("蓝");
// 添加 TabPage 到 TabControl
tabControl.TabPages.Add(tabPage1);
tabContr