RichTextBox

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
Exam Prep. Guides
70-505 Study Guide
70-526 Study Guide

1. Forms Controls

2. Integrating Data
3. Printing/Reporting
4. Enhancing Usability
5. Asynchronous Prog.
6. Forms Controls
7. Configure/Deploy

edit
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.


Inheritance hierarchy

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.Control
        System.Windows.Forms.TextBoxBase
          System.Windows.Forms.RichTextBox


Useful properties

  • AutoWordSelection - Indicates whether automatic word selection is enabled.
  • BulletIndent - Specifies the indentation used in the RichTextBox control when the bullet style is applied to the text.
  • DetectUrls - Indicates whether or not the RichTextBox will automatically format a Uniform Resource Locator (URL) when it is typed into the control.
  • EnableAutoDragDrop - When set to true, drag-and-drop operations on text, pictures, and other data is enabled. Defaulted to false.
  • Rtf - Specifies the text of the RichTextBox control, 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 a RichTextBox control.
  • 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 the RichTextBox.
  • 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 the RichTextBox.


Useful methods

  • LoadFile - Loads the contents of a file into the RichTextBox control.
  • SaveFile - Saves the contents of the RichTextBox control to a file.


Useful events

  • SelectionChanged - Occurs when the selection of text within the control has changed, such as when the SelectionStart or SelectionLength properties change.


Usage

The RichTextBox control is complex in its mastery, and therefore should not feature greatly within this context.


MSDN references


Previous_Page_.gif Next_Page_.gif
© 2007-2008 Mike Kitchen

Today's Deals: Electronics

Personal tools