SubDocument.InsertText(DocumentPosition, String) Method
Inserts the specified text at the specified position.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v24.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
#Declaration
DocumentRange InsertText(
DocumentPosition pos,
string text
)
#Parameters
Name | Type | Description |
---|---|---|
pos | Document |
A Document |
text | String | A String value specifying the text to insert. |
#Returns
Type | Description |
---|---|
Document |
A Document |
#Remarks
Consider using the SubDocument.InsertSingleLineText method instead of InsertText for inserting text without line breaks. This can enhance performance.
#Example
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.