Skip to main content

SubDocument.InsertText(DocumentPosition, String) Method

Inserts the specified text at the specified position.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

DocumentRange InsertText(
    DocumentPosition pos,
    string text
)

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

View 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);

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.

See Also