SubDocument.InsertText(DocumentPosition, String) Method
Inserts the specified text at the specified position.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v18.2.Core.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
pos | DocumentPosition | A DocumentPosition object specifying the position at which the text should be inserted. |
text | String | A String value specifying the text to insert. |
Returns
Type | Description |
---|---|
DocumentRange | A DocumentRange object representing the DocumentRange.Start and DocumentRange.End positions of the inserted text. |
Remarks
Consider using the SubDocument.InsertSingleLineText method instead of InsertText for inserting text without line breaks. This can enhance performance.
Example
Note
A complete sample project is available at https://github.com/DevExpress-Examples/wpf-richedit-document-api-t213968
document.AppendText("ABCDEFGH");
DocumentRange r1 = document.CreateRange(1, 3);
DocumentPosition pos1 = document.CreatePosition(2);
DocumentRange r2 = document.InsertText(pos1, ">>NewText<<");
string s1 = String.Format("Range r1 starts at {0}, ends at {1}", r1.Start, r1.End);
string s2 = String.Format("Range r2 starts at {0}, ends at {1}", r2.Start, r2.End);
document.Paragraphs.Append();
document.AppendText(s1);
document.Paragraphs.Append();
document.AppendText(s2);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the InsertText(DocumentPosition, String) method.
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.