RichTextBox
From Wikipedia, the free encyclopedia
The RichTextBox class (System.Windows.Forms.RichTextBox) is a .NET component that can be used to add WYSIWYG formatting including custom colours, fonts, images, tables, etc. within one TextBox-like control.
Contents |
[edit] Basic usage
A RichTextBox can be added to a windows form by dragging its icon from the Toolbox. (TODO: Add image depicting this)
The text in the control, like the TextBox control can be found in the property RichTextBox.Text
[edit] Selection
The RichTextBox's selected text is stored in the RichTextBox.SelectedText property. To query the selection length, the RichTextBox.SelectionLength property can be used, and to find the start position of the selection, the RichTextBox.SelectionStart property is used.
[edit] Formatting
This table summarizes the commands used for basic formatting:
Property Name | Description |
---|---|
SelectionAlignment | Gets or sets the alignment to apply to the current selection or insertion point. |
SelectionBackColor | Gets or sets the color of text when the text is selected in a RichTextBox control. |
SelectionBullet | Gets or sets a value indicating whether the bullet style is applied to the current selection or insertion point. |
SelectionCharOffset | Gets or sets whether text in the control appears on the baseline, as a superscript, or as a subscript below the baseline. |
SelectionColor | Gets or sets the text color of the current text selection or insertion point. |
SelectionFont | Gets or sets the font of the current text selection or insertion point. |
SelectionHangingIndent | Gets or sets 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 | Gets or sets the length, in pixels, of the indentation of the line where the selection starts. |
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. |