Font Styles

  • Thread starter Thread starter Bill English
  • Start date Start date
B

Bill English

One last question before I go to bed...
So far I have only programmed one style button for my
text. This is the code I have for my Bold button.

If Not rtb.SelectionFont Is Nothing Then
Dim currentFont As System.Drawing.Font =
rtb.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle
If rtb.SelectionFont.Bold = True Then
buttonbold.Pushed = False
newFontStyle = FontStyle.Regular
Else
buttonbold.Pushed = True
newFontStyle = FontStyle.Bold
End If
rtb.SelectionFont = New Font
(currentFont.FontFamily, currentFont.Size, newFontStyle)
rtbfont.Font = New Font
(currentFont.FontFamily, currentFont.Size, newFontStyle)
End If


Now my problem is, when this button is clicked, it
creates a new font, and it applies it to the textbox.
But when I add this code to the other buttons, they will
also create a new font. Which will mean, I can only use
one font style at once. How am I supposed to go about
programming the other buttons.
 
Hi Bill,

Is this togling of a bold button what you want to do?
\\\
If Button1.Font.Style <> FontStyle.Bold Then
Button1.Font = New Font(Button1.Font, FontStyle.Bold)
Else
Button1.Font = New Font(Button1.Font, FontStyle.Regular)
End If
////
Or did you came to something yourself after a good sleep?
:-)
Cor
 
* "Bill English said:
One last question before I go to bed...
So far I have only programmed one style button for my
text. This is the code I have for my Bold button.

If Not rtb.SelectionFont Is Nothing Then
Dim currentFont As System.Drawing.Font =
rtb.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle
If rtb.SelectionFont.Bold = True Then
buttonbold.Pushed = False
newFontStyle = FontStyle.Regular
Else
buttonbold.Pushed = True
newFontStyle = FontStyle.Bold
End If
rtb.SelectionFont = New Font
(currentFont.FontFamily, currentFont.Size, newFontStyle)
rtbfont.Font = New Font
(currentFont.FontFamily, currentFont.Size, newFontStyle)
End If


Now my problem is, when this button is clicked, it
creates a new font, and it applies it to the textbox.
But when I add this code to the other buttons, they will
also create a new font. Which will mean, I can only use
one font style at once. How am I supposed to go about
programming the other buttons.

\\\
Dim f As New Font(Me.Font, Me.Font.Style Or FontStyle.Italic)
///
 
Back
Top