ActiveReports 18 .NET Edition
Report Authors: Designer Components / Report Controls / Section Report / RichTextBox
In This Topic
    RichTextBox
    In This Topic

    The RichTextBox control is used to display, insert, and manipulate formatted text. It is different from the TextBox control in several ways. The most obvious is that it allows you to apply different formatting to different parts of its content.

    You can add fields to the text you enter directly in the RichTextBox control by right-clicking and choosing Insert Fields and providing a field name or you can load an RTF, an HTML, or a Text file into the control. 

    Note: The RichTextBox control supports loading an RTF file at design time with both CrossPlatform and GDI compatibility modes of a report. However, the RichTextBox control does not support the RTF file at run-time when the report's CompatibilityMode is set to CrossPlatform.

    Supported Formats

    ActiveReports supports most of the XHTML 1.1 standard; please see Wikipedia for more information. The limited support for reading XHTML5 and HTML5 documents is also available. The RichTextBox control supports formats such as:

    Load File Dialog

    With the control selected on the report, in the Commands section at the bottom of the Properties panel, you can click Load file to open the dialog. This allows you to select a file to load into the control at design time. Supported file types are as follows.

    RichText file

    When you load a RichText file, the control will display the file in edit mode.

    RichText file in edit mode

    Text/HTML file

    When you load a Text or an HTML file, the control will display the HTML markup in the edit mode.

    Text/HTML file in edit mode

    Important: The HTML text in an HTML file, loaded into the RichTextBox control, must be enclosed in the <body></body> tags. Otherwise, the HTML data is converted into RTF.

    Important Properties

    Property Description
    CanGrow Determines whether ActiveReports should increase the height of the control based on its content.
    CanShrink Determines whether ActiveReports should decrease the height of the field based on its value.
    RenderRtfAsContinuousImage

    If True (default), the property renders the content as one continuous image split across the pages. This property is actual if RtfRenderingType property is set to either Metafile or PNG.

    Note: This property should be set to 'False' if the RtfRenderingType property is set to a Metafile or PNG, to avoid any trimmed text at the end of the pages.
    RtfRenderingType Renders the RTF control with a legacy renderer or with the WordPad as a metafile or raster image. Only the legacy RTF renderer supports fields.
    DataField Gets or sets the field name from the data source to bind to the control.

    RichTextBox Dialog Properties

    You can set the RichTextBox properties in the RichTextBox dialog. To open it, with the RichTextBox selected on the report, under the Properties window, click the Property dialog link.

    Name: Enter a name for the RichTextBox that is unique within the report. This name is displayed in the Document Outline. You can only use underscore (_) as a special character in the Name field. Other special characters such as period (.), space ( ), forward slash (/), backslash (\), exclamation (!), and hyphen (-) are not supported.

    Tag: Enter a string that you want to persist with the control. If you access this property in code, it is an object, but in the Properties window or Property dialog, it is a string.

    Visible: Clear this check box to hide the control.

    DataField: Select a field from the data source to bind to the control.

    Max length: Enter the maximum number of characters to display in the control. If you do not specify a value, it displays an unlimited number of characters.

    Background Color: Select a color to use for the background of the control.

    RichTextBox height

    Can increase to accommodate contents: Select this check box to set CanGrow to True.

    Can decrease to accommodate contents: Select this check box to set CanShrink to True.

    Multiline: Select this check box to allow the control to display multiple lines of text.

    Supported HTML Tags and Attributes

    The RichTextBox control supports HTML tags and attributes same as the FormattedText control. For more information, please see the topic on FormattedText

    Write an RTF file to load into a RichTextBox control

    1. Open WordPad, and paste a formatted text into it, for example:

      [Paste the following section into an RTF File]
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      Customer List by Country

      Argentina

      • Rancho grande
      • Océano Atlántico Ltda.
      • Cactus Comidas para llevar

      Austria

      • Piccolo und mehr
      • Ernst Handel

      Belgium

      • Suprêmes délices
      • Maison Dewey

      Brazil

      • Familia Arquibaldo
      • Wellington Improtadora
      • Que Delícia
      • Tradição Hipermercados
      • Ricardo Adocicados
      • Hanari Carnes
      • Queen Cozinha
      • Comércio Mineiro
      • Gourmet Lanchonetes
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    2. Save the file as sample.rtf.
    Note: The RichTextBox control is limited in its support for advanced RTF features such as the ones supported by Microsoft Word. In general, the features supported by WordPad are supported in this control.

    Load an RTF file into a RichTextBox control

    1. On the report design surface, add a RichTextBox control.
    2. With the RichTextBox control selected, at the bottom of the Properties Panel, click Load file
    3. In the Open dialog that appears, browse to an *.RTF file (For example, sample.rtf) and click the Open button to load the file in the RichTextBox control.

    Write an HTML file to load into a RichTextBox control

    1. Open a Notepad, and paste an HTML code into it, for example:
      HTML code. Paste in a NotePad file.
      Copy Code
      <html>
      <body>
      <center><h1>Customer List by Country</h1></center>
      <h1>Argentina</h1>
      <ul>
      <li>Rancho grande
      <li>Océano Atlántico Ltda.
      <li>Cactus Comidas para llevar
      </ul>
      <h1>Austria</h1>
      <ul>
      <li>Piccolo und mehr
      <li>Ernst Handel
      </ul>
      <h1>Belgium</h1>
      <ul>
      <li>Suprêmes délices
      <li>Maison Dewey
      </ul>
      <h1>Brazi1>
      <ul>
      <li>Familia Arquibaldo
      <li>Wellington Improtadora
      <li>Que Delícia
      <li>Tradição Hipermercados
      <li>Ricardo Adocicados
      <li>Hanari Carnes
      <li>Queen Cozinha
      <li>Comércio Mineiro
      <li>Gourmet Lanchonetes
      </ul>
      </body>
      </html>
      
    2. Save the file as sample.html.

    Load an HTML file into the RichTextBox control

    1. On the report design surface, add a RichTextBox control.
    2. With the RichTextBox control selected, at the bottom of the Properties window, click Load file.
    3. In the Open dialog that appears, browse to a *.html file (For example, sample.html) and click the Open button to load the file in the RichTextBox control.

    ActiveReports also provides limited support for reading XHTML5 and HTML5 documents.

    Keyboard Shortcuts

    In the edit mode, you can use the following keyboard shortcuts.

    Key Combination Action
    Enter New line.
    Alt + Enter Saves modifications and exits edit mode.
    Esc Cancels modifications and exits edit mode.