Помимо кодирования события DrawItem, добавьте это событие, чтобы изменить текст вкладки в любое время.
Private Sub ChangeTabPageTextColor(ByVal TabPageIndex As Integer, ByVal ForeColor As Color)
' Get the area of the header of this TabPage
Dim HeaderRect As Rectangle = TabControl1.GetTabRect(TabPageIndex)
' Identify which TabPage is currently selected
Dim SelectedTab As TabPage = TabControl1.TabPages(TabPageIndex)
' Create a Brush to paint the Text
Dim TextBrush As New SolidBrush(ForeColor)
' Declare the text alignment variable
Dim sf As New StringFormat()
' Set the Horizontal Alignment of the Text
sf.Alignment = StringAlignment.Center
' Set the Verticle Alignment of the Text
sf.LineAlignment = StringAlignment.Near
' Declare a Font
Dim newfont As New Font(TabControl1.Font.Name, TabControl1.Font.Size, FontStyle.Regular)
' Draw the text
TabControl1.CreateGraphics().DrawString(SelectedTab.Text, newfont, TextBrush, HeaderRect, sf)
' Job done - dispose of the Brush
TextBrush.Dispose()
End Sub