16,553
社区成员
发帖
与我相关
我的任务
分享
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim g As Graphics = e.Graphics
Dim tabArea As Rectangle
Dim tabTextArea As RectangleF
Dim p As Pen
Dim font As Font
Dim brush As SolidBrush
Dim t As TabPage
Dim ti As Integer
For Each t In TabControl1.TabPages
If ti = i Then
font = New Font("Arial", 12.0F, FontStyle.Bold)
brush = New SolidBrush(Color.Red)
Else
font = New Font("Arial", 10.0F)
brush = New SolidBrush(Color.Black)
End If
p = New Pen(Color.Transparent)
tabArea = TabControl1.GetTabRect(i)
tabTextArea = RectangleF.op_Implicit(TabControl1.GetTabRect(ti))
g.DrawRectangle(p, tabArea)
g.DrawString("TabPage" & (ti + 1).ToString, font, brush, tabTextArea)
ti += 1
Next
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
i = TabControl1.SelectedIndex
TabControl1.Refresh()
End Sub