Back to Devexpress

Document.Text Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-document.md

latest4.7 KB
Original Source

Document.Text Property

Gets or sets the document’s text (plain text).

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
string Text { get; set; }
vb
Property Text As String

Property Value

TypeDescription
String

A string value that specifies the text of the document.

|

Remarks

The text is displayed using default formatting (or the text formatting specified via the RichEditAppearance.Text property).

Assigning a value to this property results in a new loaded document that is imported from the plain text format. So, all appropriate events are fired in this case. If you want to just clear the text of an existing document, use the SubDocument.Delete method with a SubDocument.Range as a parameter. This technique will not reset document properties. To wipe off the trace of this operation so it can not be undone, use the RichEditControl.ClearUndo method, as follows:

csharp
richEdit.Document.Delete(richEdit.Document.Range);
richEdit.ClearUndo();
vb
richEdit.Document.Delete(richEdit.Document.Range)
richEdit.ClearUndo()

The following code snippets (auto-collected from DevExpress Examples) contain references to the Text 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.

winforms-grid-display-edit-rtf-data/CS/Form1.cs#L68

csharp
{
    e.DisplayText = richEditControl.Document.Text;
}

wpf-rich-text-editor-customize-context-menu/CS/WpfRichEditorMenuCustomization/MainWindow.xaml.cs#L18

csharp
InitializeComponent();
richTextEditor.Document.Text = "The WPF Rich Text Editor allows you to integrate word processing " +
    "capabilities into your next WPF project. With its comprehensive text formatting options, " +

winforms-grid-display-edit-rtf-data/VB/Form1.vb#L58

vb
Private Sub riPopup_QueryDisplayText(ByVal sender As Object, ByVal e As QueryDisplayTextEventArgs)
    e.DisplayText = richEditControl.Document.Text
End Sub

wpf-rich-text-editor-customize-context-menu/VB/WpfRichEditorMenuCustomization/MainWindow.xaml.vb#L13

vb
InitializeComponent()
    richTextEditor.Document.Text = "The WPF Rich Text Editor allows you to integrate word processing " & "capabilities into your next WPF project. With its comprehensive text formatting options, " & "mail-merge, and a rich collection of end-user options you can deliver Microsoft Word-inspired " & "functionality with ease."
End Sub

See Also

RtfText

ResetText()

Text

Document Interface

Document Members

DevExpress.XtraRichEdit.API.Native Namespace