سؤال

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