Back to Devexpress

SubDocument.CreateRange(DocumentPosition, Int32) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-subdocument-dot-createrange-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-system-dot-int32-x29.md

latest7.2 KB
Original Source

SubDocument.CreateRange(DocumentPosition, Int32) Method

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

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
DocumentRange CreateRange(
    DocumentPosition start,
    int length
)
vb
Function CreateRange(
    start As DocumentPosition,
    length As Integer
) As DocumentRange

Parameters

NameTypeDescription
startDocumentPosition

A DocumentPosition object specifying the start position.

| | length | Int32 |

An integer value specifying the range length.

|

Returns

TypeDescription
DocumentRange

A DocumentRange object.

|

Exceptions

TypeDescription
ArgumentException

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

|

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

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Range.cs#L14

csharp
DocumentPosition myStart = document.CreatePosition(69);
DocumentRange myRange = document.CreateRange(myStart, 216);
document.Selection = myRange;

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/RangeActions.cs#L14

csharp
DocumentPosition myStart = document.CreatePosition(69);
DocumentRange myRange = document.CreateRange(myStart, 216);
document.Selection = myRange;

word-document-api-examples/CS/CodeExamples/BookmarksAndHyperlinks.cs#L26

csharp
// Create a bookmark at the start document position.
document.Bookmarks.Create(document.CreateRange(document.Range.Start, 0), "Top");

winforms-richedit-layout-api-practical-usage/CS/WindowsFormsApplication1/DocumentLayoutHelper/RichEditDocumentLayoutAnalyzer.cs#L14

csharp
ReadOnlyShapeCollection shapes = subDocument.Shapes.Get(subDocument.CreateRange(docPosition, 1));
ReadOnlyDocumentImageCollection images = subDocument.Images.Get(subDocument.CreateRange(docPosition, 1));

winforms-richeditcontrol-common-api/CS/RichEditAPISample/CodeExamples/RichEditControlActions.cs#L336

csharp
string currentToolTipText = String.Format("Position: {0}, Character: {1}", pos.ToString(),
    richEdit.Document.GetText(richEdit.Document.CreateRange(pos, 1)));

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Range.vb#L13

vb
Dim myStart As DevExpress.XtraRichEdit.API.Native.DocumentPosition = document.CreatePosition(69)
Dim myRange As DevExpress.XtraRichEdit.API.Native.DocumentRange = document.CreateRange(myStart, 216)
document.Selection = myRange

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/RangeActions.vb#L11

vb
Dim myStart As DocumentPosition = document.CreatePosition(69)
Dim myRange As DocumentRange = document.CreateRange(myStart, 216)
document.Selection = myRange

winforms-richedit-layout-api-practical-usage/VB/WindowsFormsApplication1/DocumentLayoutHelper/RichEditDocumentLayoutAnalyzer.vb#L17

vb
Dim shapes As ReadOnlyShapeCollection = subDocument.Shapes.Get(subDocument.CreateRange(docPosition, 1))
Dim images As ReadOnlyDocumentImageCollection = subDocument.Images.Get(subDocument.CreateRange(docPosition, 1))

winforms-richeditcontrol-common-api/VB/RichEditAPISample/CodeExamples/RichEditControlActions.vb#L345

vb
Dim currentToolTipText As String = String.Format("Position: {0}, Character: {1}", pos.ToString(),
                                                 richEdit.Document.GetText(richEdit.Document.CreateRange(pos, 1)))

word-document-api-examples/VB/CodeExamples/BookmarksAndHyperlinks.vb#L27

vb
' Create a bookmark at the start document position.
document.Bookmarks.Create(document.CreateRange(document.Range.Start, 0), "Top")
' Create a hyperlink that navigates to the created bookmark.

See Also

SubDocument Interface

SubDocument Members

DevExpress.XtraRichEdit.API.Native Namespace