The Windows FormsRichTextBoxControl has numerous options for formatting the text it displays. you can make the selected characters bold, underlined, or italic, using the selectionfont property. you can also use this property to change the size and typeface of the selected characters. the selectioncolor property allows you to change the selected characters 'color.
To change the appearance of Characters
- SetSelectionfontProperty to an appropriate font.
To enable users to set the font family, size, and typeface in an application, you wowould typically useFontdialogComponent. For an overview, see Introduction to the Windows Forms fontdialog component.
- SetSelectioncolorProperty to an appropriate color.
To enable users to set the color in an application, you wocould typically useColordialogComponent. For an overview, see Introduction to the Windows Forms colordialog component.
' Visual Basic RichTextBox1.SelectionFont = New Font("Tahoma", 12, FontStyle.Bold) RichTextBox1.SelectionColor = System.Drawing.Color.Red // C# richTextBox1.SelectionFont = new Font("Tahoma", 12, FontStyle.Bold); richTextBox1.SelectionColor = System.Drawing.Color.Red; // C++ richTextBox1->SelectionFont = new System::Drawing::Font("Tahoma", 12, FontStyle::Bold); richTextBox1->SelectionColor = System::Drawing::Color::Red;
NoteThese properties only affect selected text, or, if no text is selected, the text that is typed at the current location of the insertion point. for information on selecting text programmatically, see textboxbase. select method.
See also
RichTextBox class | RichTextBox Control (Windows Forms) | controls you can use on Windows Forms