Reputation: 730
Ok I already have a Font Dialog that changes the font of the richtextbox and it works (although I don't know how to make the apply button of the dialog work)
I also made 4 buttons for Bold, Underline, Strikethrough, and Italic.
The method I have found most people using is
Dim boldf as NewFont(....)
and then applying it to the selected text.
Problem with that is that it changes the font to only Bold, it doesn't add it to the existing style.
Please advise.
Upvotes: 2
Views: 25714
Reputation: 141
Another way to do this is:
RichTextBox1.SelectionFont.Bold = Not(RichTextBox1.SelectionFont.Bold)
Upvotes: 0
Reputation: 20469
Private Sub andlowitwasbold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles andlowitwasbold.Click
If RichTextBox1.SelectionFont.Bold Then 'its already bold, so set it to regular
RichTextBox1.SelectionFont = New Font(RichTextBox1.Font.FontFamily, RichTextBox1.Font.Size, FontStyle.Regular)
Else 'make it bold
RichTextBox1.SelectionFont = New Font(RichTextBox1.Font.FontFamily, RichTextBox1.Font.Size, FontStyle.Bold)
End If
End Sub
Upvotes: 2