Back to Devexpress

Selection.Intervals Property

blazor-devexpress-dot-blazor-dot-richedit-dot-selection-11ecddbd.md

latest1.9 KB
Original Source

Selection.Intervals Property

Gets an array of sub-document intervals in the selection.

Namespace : DevExpress.Blazor.RichEdit

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

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public IReadOnlyList<Interval> Intervals { get; }

Property Value

TypeDescription
IReadOnlyList<Interval>

A collection of interval objects.

|

Remarks

The following code snippet applies bold formatting to characters in the selected intervals.

razor
<DxRichEdit @ref="richEdit" @bind-Selection="@selection" />
@code {
    DxRichEdit richEdit { get; set; }
    Selection selection { get; set; }
    @* ... *@
        /* Surround the code that contains an asynchronous operation with a try-catch block to handle
        the OperationCanceledException. This exception is thrown when an asynchronous operation is cancelled. */
        try {
            IReadOnlyList<Interval> intervals = richEdit.Selection.Intervals;
            foreach (Interval interval in intervals) {
                TextSpan boldTextSpan = await richEdit.DocumentAPI.GetTextSpanAsync(interval);
                await boldTextSpan.ChangePropertiesAsync(properties => {
                    properties.FontBold = true;
                });
            }
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

See Also

Selection Class

Selection Members

DevExpress.Blazor.RichEdit Namespace