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
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
DocumentRange CreateRange(
DocumentPosition start,
int length
)
Function CreateRange(
start As DocumentPosition,
length As Integer
) As DocumentRange
| Name | Type | Description |
|---|---|---|
| start | DocumentPosition |
A DocumentPosition object specifying the start position.
| | length | Int32 |
An integer value specifying the range length.
|
| Type | Description |
|---|---|
| DocumentRange |
A DocumentRange object.
|
| Type | Description |
|---|---|
| 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
DocumentPosition myStart = document.CreatePosition(69);
DocumentRange myRange = document.CreateRange(myStart, 216);
document.Selection = myRange;
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/RangeActions.cs#L14
DocumentPosition myStart = document.CreatePosition(69);
DocumentRange myRange = document.CreateRange(myStart, 216);
document.Selection = myRange;
word-document-api-examples/CS/CodeExamples/BookmarksAndHyperlinks.cs#L26
// Create a bookmark at the start document position.
document.Bookmarks.Create(document.CreateRange(document.Range.Start, 0), "Top");
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
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
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
Dim myStart As DocumentPosition = document.CreatePosition(69)
Dim myRange As DocumentRange = document.CreateRange(myStart, 216)
document.Selection = myRange
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
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
' 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