Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

SubDocument.CreateRange(Int32, Int32) Method

Creates a new document range using the specified start position and range length.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

Declaration

DocumentRange CreateRange(
    int start,
    int length
)

Parameters

Name Type Description
start Int32

An integer value specifying the start position.

length Int32

An integer value specifying the range length.

Returns

Type Description
DocumentRange

A DocumentRange object.

Exceptions

Type Description
ArgumentException

Throws if the negative value is passed as the start parameter.

Example

The code sample below obtains a range and calls the SubDocument.InsertText method to insert a text as follows:

ABNewTextCDEFGH

Range r1 starts at 1, ends at 11

Range r2 starts at 2, ends at 9

View Example

Document document = wordProcessor.Document;
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 CreateRange(Int32, Int32) 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