A newer version of this page is available. Switch to the current version.

XRRichText Class

A Rich Text control which is used to display formatted text in a report.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll


public class XRRichText :


The XRRichText control allows you to display formatted text in your report. It can represent static or dynamic text, or both.

In addition to the capability to embed plain text into your report (using the Label control), you may need to display RTF or HTML content as well. This allows you to easily perform extraction of RTF or HTML content from a database field, and load content from a file.


When exporting to XLS or XLSX formats, XRRichText’s content is exported as plain text only.

To load RTF or HTML content into the XRRichText control from a file, click its smart tag and in the invoked actions list, select Load File….


Then, in the invoked Open dialog, use the drop-down list to define the file’s extension (.rtf, .docx, .txt, .htm or .html), select the file, and click Open.

You can quickly modify the XRRichText control’s displayed content using its in-place editor and the Formatting Toolbar.



Bind a Rich Text Control to Data

To display RTF content within an XRRichText control, bind its XRRichText.Rtf property to a data field obtained from the data source. To do this, click the control’s smart tag, expand the Rtf Expression drop-down list and select the required data field.


In the same way, you can bind the XRRichText control to a data field that provides HTML content using the XRRichText.Html property. For this, click the control’s smart tag and use the Html Expression option. To learn more on HTML support, refer to HTML Tag Support.

Clicking the Rtf Expression or Html Expression option’s ellipsis button invokes the Expression Editor, in which you can construct a complex binding expression involving two or more data fields. You can also invoke the Expression Editor and specify the XRRichText.Rtf and XRRichText.Html properties using the Properties window.


To quickly create an XRichText control that is bound to a data field of any type, right-click the corresponding node of the Field List and drop it onto a report band. In the invoked context menu, choose the RichText item.


Note that the mail merge feature is fully supported for the XRRichText control, meaning that you can easily embed data fields and images into its content.


See the Bind Report Controls to Data topic to learn more about available data binding modes and creating data-aware controls.


The following method demonstrates how to create an XRRichText object, set some of its properties, and then save its contents to a text file.

using System;
using DevExpress.XtraReports.UI;
// ...

public XRRichText CreateXRRichText(){
    // Create an XRRichText object.
    XRRichText xrRichText1 = new XRRichText();

    // Set its height to be calculated automatically,
    // and make its borders visible.
    xrRichText1.CanGrow = true;
    xrRichText1.CanShrink = true;         
    xrRichText1.Borders = DevExpress.XtraPrinting.BorderSide.All;

    // Create an array of lines and assign it to the rich text.
    string[] boxLines = new String[3];
    boxLines[0] = "Line 1";
    boxLines[1] = "Line 2";
    boxLines[2] = "Line 3";
    xrRichText1.Lines = boxLines;

    // Export its contents to a text file.
    xrRichText1.SaveFile("output.txt", XRRichTextStreamType.PlainText);

    return xrRichText1;


See Also