Post by bobowk on Jun 25, 2016 10:43:32 GMT 10
After I change the size of my font, it seems to reset the fontstyle to regular. I have followed Nathan Lecompte 's attempt but it didn't seem to help... Here is my code for the bold, italic and underline: Private Sub ButtonBold_Click(sender As System.Object, e As System.EventArgs) Handles ButtonBold.Click
Dim font_style_set As New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Xor FontStyle.Bold)
If RichTextBox1.SelectionFont IsNot Nothing Then
RichTextBox1.SelectionFont = font_style_set
If ButtonBold.BackColor = Color.WhiteSmoke Then
ButtonBold.BackColor = Color.Gainsboro
Else
ButtonBold.BackColor = Color.WhiteSmoke
End If
Else
RichTextBox1.SelectionFont = font_style_set
If ButtonBold.BackColor = Color.WhiteSmoke Then
ButtonBold.BackColor = Color.Gainsboro
Else
ButtonBold.BackColor = Color.WhiteSmoke
End If
End If
End Sub
Private Sub ButtonItalic_Click(sender As System.Object, e As System.EventArgs) Handles ButtonItalic.Click
Dim font_style_set As New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Xor FontStyle.Italic)
RichTextBox1.SelectionFont = font_style_set
If ButtonItalic.BackColor = Color.WhiteSmoke Then
ButtonItalic.BackColor = Color.Gainsboro
Else
ButtonItalic.BackColor = Color.WhiteSmoke
End If
End Sub
Private Sub ButtonUnderlined_Click(sender As System.Object, e As System.EventArgs) Handles ButtonUnderlined.Click
Dim font_style_set As New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Xor FontStyle.Underline)
RichTextBox1.SelectionFont = font_style_set
If ButtonUnderlined.BackColor = Color.WhiteSmoke Then
ButtonUnderlined.BackColor = Color.Gainsboro
Else
ButtonUnderlined.BackColor = Color.WhiteSmoke
End If
End Sub
Private Sub ButtonStrikeout_Click(sender As System.Object, e As System.EventArgs) Handles ButtonStrikeout.Click
Dim font_style_set As New Font(RichTextBox1.SelectionFont, RichTextBox1.SelectionFont.Style Xor FontStyle.Strikeout)
RichTextBox1.SelectionFont = font_style_set
If ButtonStrikeout.BackColor = Color.WhiteSmoke Then
ButtonStrikeout.BackColor = Color.Gainsboro
Else
ButtonStrikeout.BackColor = Color.WhiteSmoke
End If
End Sub And here is my change size code: If RichTextBox1.SelectionFont IsNot Nothing Then RichTextBox1.SelectionFont = New Font(ComboBox1.Text, ComboBox2.Text) UpdateProperties() Else RichTextBox1.SelectionFont = New Font(ComboBox1.Text, ComboBox2.Text) UpdateProperties() End If
Last Edit: Jun 25, 2016 22:30:59 GMT 10 by bobowk
|
|
Post by bobowk on Jun 25, 2016 22:31:26 GMT 10
Figured it out! But to those who need it:
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont.FontFamily, CInt(ComboBox2.Text), RichTextBox1.SelectionFont.Style)
|
|