how can I place both Bold & Italic togther

shahare

Newcomer
Joined
Oct 4, 2008
Messages
1
This is the code I entered according to websites I found some info:

========================================================
If ((toCheckBold = False) And (toCheckItalic = False)) Then
lblToChange.Font = New Font(lblToChange.Font, FontStyle.Bold)
ElseIf ((toCheckBold = False) And (toCheckItalic = True)) Then
lblToChange.Font = New Font(lblToChange.Font, FontStyle.Bold)
lblToChange.Font = New Font(lblToChange.Font, FontStyle.Italic)
ElseIf ((toCheckBold = True) And (toCheckItalic = False)) Then
lblToChange.Font = New Font(lblToChange.Font, FontStyle.Regular)
ElseIf ((toCheckBold = True) And (toCheckItalic = True)) Then
lblToChange.Font = New Font(lblToChange.Font, FontStyle.Regular)
lblToChange.Font = New Font(lblToChange.Font, FontStyle.Italic)
End If
========================================================

The problem is that the new definition for the font rams the old one.
How do I set them to be both Italic and Bold?

Thanks
Shahar
 
Code:
lblToChange.Font = [COLOR="Blue"]New [/COLOR]Font(lblToChange.Font, [I]FontStyle.Italic [COLOR="Blue"]Or [/COLOR]FontStyle.Bold[/I])
 
That is because they are now flags, so when you say

FontStyle.Italic or FontStyle.Bold

you are using the binarmy math on those two, thus turning on both bits.

See this for further clarification.
 
Back
Top