VB.NET
Private
Sub
TabControl1_DrawItem(
ByVal
sender
As
System.Object,
e
System.Windows.Forms.DrawItemEventArgs)
Handles
TabControl1.DrawItem
' Me.TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed ' 必须先改变模式(可将此句放在Load事件上)
Dim tabArea Rectangle
tabTextArea RectangleF
tabArea = TabControl1.GetTabRect(e.Index)
tabTextArea CType (TabControl1.GetTabRect(e.Index),RectangleF)
' Me.TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed ' 必须先改变模式(可将此句放在Load事件上)
Dim tabArea Rectangle
tabTextArea RectangleF
tabArea = TabControl1.GetTabRect(e.Index)
tabTextArea CType (TabControl1.GetTabRect(e.Index),RectangleF)
g
Graphics
e.Graphics
sf StringFormat New StringFormat()
sf.LineAlignment StringAlignment.Center
sf.Alignment StringAlignment.Center
sf StringFormat New StringFormat()
sf.LineAlignment StringAlignment.Center
sf.Alignment StringAlignment.Center
font
Font
Me
.TabControl1.Font
brush SolidBrush SolidBrush(Color.Black)
g.DrawString(( (sender,TabControl)).TabPages(e.Index).Text,font,brush,tabTextArea,sf)
End Sub
brush SolidBrush SolidBrush(Color.Black)
g.DrawString(( (sender,TabControl)).TabPages(e.Index).Text,font,brush,tabTextArea,sf)
End Sub
private void tabControl1_DrawItem(object sender,DrawItemEventArgs e) { //this.tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed; 必须先改变模式(可将此句放在Load事件上) Rectangle tabArea; RectangleF tabTextArea; tabArea = tabControl1.GetTabRect(e.Index); tabTextArea = (RectangleF)tabControl1.GetTabRect(e.Index); Graphics g = e.Graphics; StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; Font font = this.tabControl1.Font; SolidBrush brush = SolidBrush(Color.Black); g.DrawString(((TabControl)(sender)).TabPages[e.Index].Text,sf); }原文链接:https://www.f2er.com/vb/259970.html