ここでのコメントの大部分に同意します。標準の TabControl は、Microsoft の Part では非常にうまく描画されません... Windows Vista / 7 でも見栄えがよくありません! TabControl を継承し、必要な追加要素を描画して、独自のカスタム実装を作成することをお勧めします。
これを新しいコントロールのテンプレートとして使用することを検討してください。OnPaint および OnPaintBackground メソッドにクールなデザイン/描画作業を追加するだけです。
namespace CustomControls
{
#region USING
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
#endregion
public class CustomTabControl : TabControl
{
#region VARIABLES
private int hotTrackTab = -1;
#endregion
#region INSTANCE CONSTRUCTORS
public CustomTabControl() : base()
{
this.InitializeComponent();
}
#endregion
#region INSTANCE METHODS
private void InitializeComponent()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.DrawMode = TabDrawMode.OwnerDrawFixed;
}
private int GetTabUnderCursor()
{
Point cursor = this.PointToClient(Cursor.Position);
for (int index = 0; index < this.TabPages.Count; index++)
{
if (this.GetTabRect(index).Contains(cursor))
{
return index;
}
}
return -1;
}
private void UpdateHotTrack()
{
int hot = GetTabUnderCursor();
if (hot != this.hotTrackTab)
{
if (this.hotTrackTab != -1)
{
this.Invalidate(this.GetTabRect(this.hotTrackTab));
}
this.hotTrackTab = hot;
if (this.hotTrackTab != -1)
{
this.Invalidate(this.GetTabRect(this.hotTrackTab));
}
this.Update();
}
}
#endregion
#region OVERRIDE METHODS
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
this.UpdateHotTrack();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
this.UpdateHotTrack();
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
this.UpdateHotTrack();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
switch (this.Alignment)
{
case TabAlignment.Bottom:
case TabAlignment.Left:
case TabAlignment.Right:
case TabAlignment.Top:
default:
throw new NotImplementedException();
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);
}
#endregion
}
}
上記のコードは、DisplayRectangle のみを表示する完全に空の TabControl を描画することに注意してください。あなたが自分で行う必要があるタブを含む他のすべて!
さらに、個々の TabPages の背景を描画するには、TabPage をオーバーライドしてカスタム実装する必要がある場合もありますが、カスタム タブ コントロールだけで探している結果を達成できる場合があります。
これをチェックして
ください http://www.codeproject.com/Articles/42046/Customized-TabControl-by-Repainting-Microsoft-s-Pa
私見これは良いです...
http://www.codeproject.com/Articles/38014/KRBTabControl
私見これはまだ良いです...
http://www.codeproject.com/Articles/91387/Painting-Your-Own-Tabs-Second-Edition
また、VB フォーラムを参照してください...素晴らしいカスタム タブ コントロールがそこにあるようです。