Visual Basic: RichTextBox Control
SelFontName Property Example
This example displays a font dialog box from a CommonDialog control to specify font attributes of selected text in a RichTextBox control. To try this example, put a RichTextBox control, a CommandButton control, and a CommonDialog control on a form. Paste this code into the Click event of the CommandButton control. Then run the example.
Private Sub Command1_Click ()
CommonDialog1.Flags = cdlCFBoth
CommonDialog1.ShowFont
With RichTextBox1
.SelFontName = CommonDialog1.FontName
.SelFontSize = CommonDialog1.FontSize
.SelBold = CommonDialog1.FontBold
.SelItalic = CommonDialog1.FontItalic
.SelStrikethru = CommonDialog1.FontStrikethru
.SelUnderline = CommonDialog1.FontUnderline
End With
End Sub