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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top