嘿,我一直在試圖畫我自己的TabControl來擺脫3D陰影,但我沒有太大的成功。 DrawItem事件此刻不會觸發。我必須自己拍攝嗎?我怎麼做?TabControl.DrawItem不會觸發用戶繪製的TabControl
代碼:
namespace NCPad
{
public partial class NCE_TabControl : TabControl
{
Rectangle TabBoundary;
RectangleF TabTextBoundary;
public NCE_TabControl()
{
InitializeComponent();
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
this.DrawMode = TabDrawMode.OwnerDrawFixed;
this.Paint += new PaintEventHandler(this.OnPaint);
this.DrawItem += new DrawItemEventHandler(this.OnDrawItem);
}
protected void OnPaint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(Color.Red), e.ClipRectangle);
}
protected void OnDrawItem(object sender, DrawItemEventArgs e)
{
Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(Color.Blue), this.TabBoundary);
MessageBox.Show("hi");
}
protected override void OnLayout(LayoutEventArgs levent)
{
base.OnLayout(levent);
this.TabBoundary = this.GetTabRect(0);
this.TabTextBoundary = (RectangleF)this.GetTabRect(0);
}
}
}
我試圖調用(),但我給自己買了一個不錯的異常。 :( – 2010-06-25 03:37:53
現在我試圖在OnPaint事件過程中遍歷TabPages並使它們失效,但它仍然沒有引發DrawItem事件 – 2010-06-25 04:00:05
如果我添加自己的事件並在循環訪問標籤頁時提高它,但它工作正常但 – 2010-06-25 20:22:58