Back to Devexpress

DocumentRange.Length Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentrange-a4ebeb8f.md

latest6.6 KB
Original Source

DocumentRange.Length Property

Gets the length of a document range in characters.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
int Length { get; }
vb
ReadOnly Property Length As Integer

Property Value

TypeDescription
Int32

An integer, representing the number of character positions in a range.

|

Remarks

Use the SubDocument.CreateRange method to create a document range of the required length.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Length property.

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-save-text-from-a-range-in-different-formats/CS/GetTextMethodsExample/Form1.cs#L29

csharp
#region #exportmht
if (this.richEditControl.Document.Selection.Length > 0)
{

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Export.cs#L34

csharp
// Get the range for three paragraphs.
DocumentRange r = document.CreateRange(document.Paragraphs[0].Range.Start, document.Paragraphs[0].Range.Length + document.Paragraphs[1].Range.Length + document.Paragraphs[2].Range.Length);
// Export to HTML.

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/ExportActions.cs#L35

csharp
// Get the range for three paragraphs.
DocumentRange r = document.CreateRange(document.Paragraphs[0].Range.Start, document.Paragraphs[0].Range.Length + document.Paragraphs[1].Range.Length + document.Paragraphs[2].Range.Length);
// Export to HTML.

word-document-api-examples/CS/CodeExamples/NotesActions.cs#L71

csharp
DocumentRange noteTextRange = footnote.CreateRange(footnote.Range.Start.ToInt() + 2,
    footnote.Range.Length - 2);

word-document-api-use-track-changes/CS/Program.cs#L66

csharp
//Keep text from the location whose range is the smallest
    e.ResolveMode = (e.OriginalLocationRange.Length <= e.NewLocationRange.Length) ? TrackedMovesConflictResolveMode.KeepOriginalLocationText : TrackedMovesConflictResolveMode.KeepNewLocationText;
}

winforms-richedit-save-text-from-a-range-in-different-formats/VB/GetTextMethodsExample/Form1.vb#L26

vb
Try
    If Me.richEditControl.Document.Selection.Length > 0 Then
        Dim selection As DevExpress.XtraRichEdit.API.Native.DocumentRange = richEditControl.Document.Selection

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Export.vb#L30

vb
' Get the range for three paragraphs.
Dim r As DevExpress.XtraRichEdit.API.Native.DocumentRange = document.CreateRange(document.Paragraphs(CInt((0))).Range.Start, document.Paragraphs(CInt((0))).Range.Length + document.Paragraphs(CInt((1))).Range.Length + document.Paragraphs(CInt((2))).Range.Length)
' Export to HTML.

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/ExportActions.vb#L30

vb
' Get the range for three paragraphs.
Dim r As DocumentRange = document.CreateRange(document.Paragraphs(0).Range.Start, document.Paragraphs(0).Range.Length + document.Paragraphs(1).Range.Length + document.Paragraphs(2).Range.Length)
' Export to HTML.

word-document-api-examples/VB/CodeExamples/NotesActions.vb#L62

vb
' Exclude the reference mark and the space after it from the range that is edited.
Dim noteTextRange As DevExpress.XtraRichEdit.API.Native.DocumentRange = footnote.CreateRange(footnote.Range.Start.ToInt() + 2, footnote.Range.Length - 2)
' Clear the range.

word-document-api-use-track-changes/VB/Program.vb#L60

vb
'Keep text from the location whose range is the smallest
    e.ResolveMode = If(e.OriginalLocationRange.Length <= e.NewLocationRange.Length, TrackedMovesConflictResolveMode.KeepOriginalLocationText, TrackedMovesConflictResolveMode.KeepNewLocationText)
End Sub

See Also

Selection

DocumentRange Interface

DocumentRange Members

DevExpress.XtraRichEdit.API.Native Namespace