RichTextBox
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| Exam 70-526 Preparation Guide: Create and Configure Text Edit Controls on a Windows Form |
Contents |
The RichTextBox control enables text to be displayed with formatting in plain text or rich-text format (RTF). To see a RichTextBox Control in action open up WordPad.
A RichTextBox allows individual characters inside it to be formatted in any font or colour you like, as well as being able to accept images, and align paragraphs. It derives from the same parent class as TextBox and hence shares most of the same properties and methods. In addition, the ability to handle RTF documents is included.
One of the key properties of a RichTextBox is the ability to manipulate the currently selected piece of text.
[edit]
Inheritance hierarchy
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.TextBoxBase
System.Windows.Forms.RichTextBox
[edit]
Useful properties
-
AutoWordSelection- Indicates whether automatic word selection is enabled.
-
-
BulletIndent- Specifies the indentation used in theRichTextBoxcontrol when the bullet style is applied to the text.
-
-
DetectUrls- Indicates whether or not theRichTextBoxwill automatically format a Uniform Resource Locator (URL) when it is typed into the control.
-
-
EnableAutoDragDrop- When set totrue, drag-and-drop operations on text, pictures, and other data is enabled. Defaulted tofalse.
-
-
Rtf- Specifies the text of theRichTextBoxcontrol, including all rich text format (RTF) codes.
-
-
SelectedRtf- Indicates the currently selected rich text format (RTF) formatted text in the control.
-
-
SelectionAlignment- Specifies the alignment to apply to the current selection or insertion point.
-
-
SelectionBackColor- Indicates the colour of text when the text is selected in aRichTextBoxcontrol.
-
-
SelectionBullet- Indicates whether the bullet style is applied to the current selection or insertion point.
-
-
SelectionCharOffset- Indicates whether text in the control appears on the baseline, as a superscript, or as a subscript below the baseline.
-
-
SelectionColor- Specifies the text colour of the current text selection or insertion point.
-
-
SelectionFont- Specifies the font of the current text selection or insertion point.
-
-
SelectionHangingIndent- Specifies the distance between the left edge of the first line of text in the selected paragraph and the left edge of subsequent lines in the same paragraph.
-
-
SelectionIndent- Specifies the length, in pixels, of the indentation of the line where the selection starts.
-
-
SelectionProtected- Indicates whether the current text selection is protected.
-
-
SelectionRightIndent- The distance (in pixels) between the right edge of the RichTextBox control and the right edge of the text that is selected or added at the current insertion point.
-
-
ShowSelectionMargin- Indicates whether a selection margin is displayed in theRichTextBox.
-
-
WordWrap- Indicates whether a multi-line text box control automatically wraps words to the beginning of the next line when necessary.
-
-
ZoomFactor- Gets or sets the current zoom level of theRichTextBox.
-
[edit]
Useful methods
-
LoadFile- Loads the contents of a file into theRichTextBoxcontrol.
-
-
SaveFile- Saves the contents of theRichTextBoxcontrol to a file.
-
[edit]
Useful events
-
SelectionChanged- Occurs when the selection of text within the control has changed, such as when the SelectionStart or SelectionLength properties change.
-
[edit]
Usage
The RichTextBox control is complex in its mastery, and therefore should not feature greatly within this context.
[edit]
MSDN references
|
© 2007-2008 Mike Kitchen

