Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Selection(SubDocument, Interval[]) Constructor

Initializes a new instance of the Selection class and selects the specified intervals.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public Selection(
    SubDocument subDocument,
    params Interval[] intervals
)

#Parameters

Name Type Description
subDocument SubDocument

The sub-document that contains the selection.

intervals Interval[]

The intervals to select.

#Remarks

Call this constructor to select several intervals in Rich Text Editor. To access the editor’s selection in code, bind the Selection property with @bind-Selection attribute.

Razor
<DxRichEdit @bind-Selection="@selection" @ref="@richEdit" />

@code {
    DxRichEdit richEdit;
    Selection selection;
    @* ... *@
    /* 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 canceled. */
        try {
        @* ... *@
            Interval[] myIntervals = { new Interval(4, 6), new Interval(97, 6) };
            selection = new Selection(richEdit.DocumentAPI, myIntervals);
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

The image below shows the result.

Rich Edit - Select several intervals

Handle the SelectionChanged event to react to changes in selection.

See Also