The RichTextBox control for Windows Forms is used for displaying, typing and formatting of text. The control RichTextBox does everything the control of the TextBox does but can show fonts, colors and links; load images and text from a file; and find the characters that we specify.
The RichTextBox control is typically used for manipulating texts and displaying functionality similar to text processing applications such as Microsoft Word. Like Textbox, scroll bars can be displayed with RichTextBox control ; unlike TextBox, its default configuration is to show scroll bars both horizontal and vertical as required and has extra scroll bar configurations.
The text displayed is set by the Text property, just like the TextBox command. The controller RichTextBox has many text formatting characteristics.
How to Set Font Attributes for RichTextBox Control?
How to Set Indents, Hanging Indents, and Bulleted Paragraphs with RichTextBox Control?
To format a paragraph as a bulleted list
To indent a paragraph
The LoadFile and SaveFile processes can show and write several file format including plain text, Unicode plain text and Rich Text Format (RTF) to manipulate documents.
The possible file formats are listed in RichTextBoxStreamType
Specifies the input and output stream types for loading and saving data in the RichTextBox control.
Fields | Description | |
Rich Text | 0 | A RTF (Rich Text Format) stream. |
PlainText | 1 | A plain text stream containing space in OLE (objects Linking and Embedding) objects. |
TextTextOleObjs | 2 | A plain text stream, representing OLE objects textually. This is valid only for use with the RichTextBox, SaveFile(String) method. |
UnicodePlainText | 3 | A text stream that includes object spaces instead of objects linked and embedded (OLE). In Unicode, the text is encoded. |
RichNoOleObjs | 4 | A Rich Text Format (RTF) stream with OLE objects spaces. This value is valid only for use with the RichTextBox control, SaveFile(String) method. |
For links in web-type style, we can also use a RichTextBox control by setting DetectUrls
to true
and write code to handle the LinkClicked
event.
By setting the SelectionProtected
property to true
, we can stop the user from manipulate some or all of the text in the control.
By using the Undo
and Redo
techniques, We can undo and rework most of the operations in a RichTextBox control. The CanRedo
method can help us decide if the control can be reapplied to the last operation that the user has undone.
Complete Source Code
We use cookies to ensure you get the best experience on our website, if you continue to browse you'll be acconsent with our Cookies Policy.
Got it!