running32
asked on
Change text in tab control
I would like to change the Font size and color of the text on my tab control when I click it. I have 5 tabs but each looks the same. How can I change the font of the header when i click. Thanks
I tried TabPage1.Font = New Font("Microsoft Sans Serif", 14, FontStyle.Bold) but that does not change the heading font.
thanks
I tried TabPage1.Font = New Font("Microsoft Sans Serif", 14, FontStyle.Bold) but that does not change the heading font.
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Very good, grasshopper!!
Bob
Bob
ASKER
Thanks for being so quick to respond to the question. I always appreciate your input.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeap, that's the one. Thanks
ASKER
Private Sub TabControl1_DrawItem(ByVal
'Firstly we'll define some parameters.
Dim CurrentTab As TabPage = TabControl1.TabPages(e.Ind
Dim ItemRect As Rectangle = TabControl1.GetTabRect(e.I
Dim FillBrush As New SolidBrush(Color.Red)
Dim TextBrush As New SolidBrush(Color.White)
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
'If we are currently painting the Selected TabItem we'll
'change the brush colors and inflate the rectangle.
If CBool(e.State And DrawItemState.Selected) Then
FillBrush.Color = Color.White
TextBrush.Color = Color.Red
ItemRect.Inflate(2, 2)
End If
'Set up rotation for left and right aligned tabs
If TabControl1.Alignment = TabAlignment.Left Or TabControl1.Alignment = TabAlignment.Right Then
Dim RotateAngle As Single = 90
If TabControl1.Alignment = TabAlignment.Left Then RotateAngle = 270
Dim cp As New PointF(ItemRect.Left + (ItemRect.Width \ 2), ItemRect.Top + (ItemRect.Height \ 2))
e.Graphics.TranslateTransf
e.Graphics.RotateTransform
ItemRect = New Rectangle(-(ItemRect.Heigh
End If
'Next we'll paint the TabItem with our Fill Brush
e.Graphics.FillRectangle(F
'Now draw the text.
e.Graphics.DrawString(Curr
'Reset any Graphics rotation
e.Graphics.ResetTransform(
'Finally, we should Dispose of our brushes.
FillBrush.Dispose()
TextBrush.Dispose()
End Sub