Skip to main content

Selection.Intervals Property

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

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public IReadOnlyList<Interval> Intervals { get; }

Property Value

Type Description
IReadOnlyList<Interval>

A collection of interval objects.

Remarks

The code sample below applies bold formatting to characters in the selected intervals.

<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