How to: Format Characters in a RichTextBox Control
This example writes a sentence, which contains three words in three different font styles (bold, italic, and underlined), to an existing RichTextBox control.
Example
richTextBox1.Rtf = @"{\rtf1\ansi This text is in \b bold\b0, " +
@"this is in \i italics\i0, " +
@"and this is \ul underlined\ul0.}";
Compiling the Code
This example requires:
- A RichTextBox control named richTextBox1. Insert the code into the Form1_Load method.
Robust Programming
The rich text format is very flexible, but any errors in the format lead to errors in the displayed text.
See Also
Concepts
Designing a User Interface in Visual C#
Other Resources
Change History
Date |
History |
Reason |
---|---|---|
September 2008 |
Added instructions about where to insert the code. |
Customer feedback. |