MAUI | ComponentOne
Controls / FlexGrid / Selection
In This Topic
    Selection
    In This Topic

    FlexGrid, by default, allows to select a continuous batch of cells using mouse or keyboard and entire row or column by clicking the corresponding header. However, the default behavior can be changed to allow selection in units of cell, row, column etc. by using SelectionMode property of the C1GridControl class. The property accepts values from the GridSelectionMode enumeration. The following table gives a quick snapshot of how selection looks like in each of these modes.

    Value Description Snapshot
    None Disables selection of cells in FlexGrid control. disable cell selection
    Cell Allows selection of single cell at a time. single cell selection
    CellRange Allows selection of continuous batch of cells using mouse or keyboard. cell range selection
    Column Allows selection of single column at a time. single column selection
    ColumnRange Allows selection of multiple contiguous columns at a time. column range selection
    Row Allows selection of single row at a time. single row selection
    RowRange Allows selection of multiple contiguous rows at a time. row range selection
    MultiRange Allows selection of collection of ranges.
    ListBox Allows selection of non-contiguous rows by ctrl+clicking.
    MultiColumns Allows selection of non-contiguous columns by ctrl+clicking.

    The following code shows how to set selection for a cell range using the SelectionMode property. This example uses the sample created in the Quick Start topic.

    <c1:FlexGrid x:Name="grid" AutoGenerateColumns="False" SelectionMode="CellRange">
        <c1:FlexGrid.Columns>
            <c1:GridColumn Binding="FirstName" />
            <c1:GridColumn Binding="LastName" />
            <c1:GridColumn Binding="City"/>
            <c1:GridColumn Binding="Country"/>
            <c1:GridColumn Binding="Active"/>
        </c1:FlexGrid.Columns>
    </c1:FlexGrid>
    
    // set the selection mode
    grid.SelectionMode = GridSelectionMode.CellRange;