日期:2014-05-17 浏览次数:21313 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1.june
{
public partial class TabTest : Form
{
public TabTest()
{
InitializeComponent();
}
private void TabTest_Load(object sender, EventArgs e)
{
//清空控件
//this.MainTabControl.TabPages.Clear();
//绘制的方式OwnerDrawFixed表示由窗体绘制大小也一样
this.MainTabControl.DrawMode = TabDrawMode.OwnerDrawFixed;
this.MainTabControl.Padding = new System.Drawing.Point(CLOSE_SIZE, CLOSE_SIZE);
this.MainTabControl.DrawItem += new DrawItemEventHandler(this.MainTabControl_DrawItem);
this.MainTabControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MainTabControl_MouseDown);
}
const int CLOSE_SIZE = 15;
//tabPage标签图片
Bitmap image = new Bitmap("E:\\ico_close.gif");
//绘制“X”号即关闭按钮
private void MainTabControl_DrawItem(object sender, DrawItemEventArgs e)
{
try