Search code examples
vb.netuser-interfacerichedit

Font attributes of RichEdit control


I am using old good RichEdit control with last version of VB.NET I want to set font attributes for text which will be typed from now and then. So, RichEdit.Font and RichEdit.SelectedFont are not an options.

What should be the correct approach?

Thank you in advance.


Solution

  • It is in fact SelectionFont. Some sample code, try it with a button and an RTB dropped on a form:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With RichTextBox1
            .SelectionLength = 0
            .SelectionFont = New Font(.Font, FontStyle.Bold)
            .Focus()
        End With
    End Sub
    

    Type something, click the button, note how everything you type now is bold.