Back to Devexpress

RichEditControl.RtfText Property

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-2c6a3674.md

latest4.6 KB
Original Source

RichEditControl.RtfText Property

Gets or sets the formatted text content of the control.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
[Bindable(true)]
[Browsable(false)]
public string RtfText { get; set; }
vb
<Bindable(True)>
<Browsable(False)>
Public Property RtfText As String

Property Value

TypeDescription
String

A string, containing the document’s content in rich text format.

|

Remarks

Use this property to load an RTF content to the RichEditControl.

The RtfText property value is loaded as a new document in the rich text format. Check the RtfText property value when the RichEditControl.DocumentLoaded event handler, i.e. when the document is fully loaded.

The following code snippet displays the word “Test” in blue.

View Example

csharp
string rtfString = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1049
{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}
{\f1\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue255;}
\viewkind4\uc1\pard\cf1\lang1033\b\f0\fs32 Test.\cf0\b0\f1\fs20\par}";
            document.RtfText = rtfString;
vb
Dim rtfString As String = "{\rtf1\ansi\ansicpg1252\deff0\deflang1049{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}}{\colortbl ;\red0\green0\blue255;}\viewkind4\uc1\pard\cf1\lang1033\b\f0\fs32 Test.\cf0\b0\f1\fs20\par}"
document.RtfText = rtfString

The following code snippets (auto-collected from DevExpress Examples) contain references to the RtfText property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

how-to-load-a-document-into-the-richedit-control/CS/LoadDocumentExample/Form1.cs#L46

csharp
#region #fromstring
            richEditControl1.RtfText = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1049
{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}

word-processing-merge-documents-with-different-headers-and-footers/CS/DocumentMerger/Form1.cs#L26

csharp
Document mergedDoc = DocumentsMerger.MergeDouments(filenames);
    richEditControl1.RtfText = mergedDoc.RtfText;
}

how-to-load-a-document-into-the-richedit-control/VB/LoadDocumentExample/Form1.vb#L41

vb
' #Region "#fromstring"
richEditControl1.RtfText = "{\rtf1\ansi\ansicpg1252\deff0\deflang1049" &
                            "{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}" &

word-processing-merge-documents-with-different-headers-and-footers/VB/DocumentMerger/Form1.vb#L21

vb
Dim mergedDoc As Document = DocumentsMerger.MergeDouments(filenames)
    richEditControl1.RtfText = mergedDoc.RtfText
End Sub

See Also

Text

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace