GridView Rows Selection

1 Answer 3 Views
GridView
Park
Top achievements
Rank 1
Park asked on 03 Feb 2026, 02:34 PM

 

Hello.

I'm currently using VS2019, Telerik version 2021.3.914.40.

When I Shift-click and then MouseDown on a row in radGridView,

the last clicked RowIndex is internally saved.

When I Shift + MouseDown, the last clicked RowIndex is set as the StartIndex, and the last clicked RowIndex is set as the EndIndex.

I'd like to reset this internal RowIndex, which is saved by the last click.

Since GridView.ClearSelection() doesn't handle this code, I've attached the relevant project. Please check.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 03 Feb 2026, 02:56 PM

Hi Park,

The provided information is greatly appreciated.

To confirm that we are on the same page. You want to clear the selection, the second time the user clicks on a row while the Shift key is held. This scenario is a little tricky. Internally, the control is using the BaseGridNavigator class that holds the selection logic. Internally, it saved a sequence of when the end user clicks on a row. A possible way to achieve this is to interfere with the default selection logic of the control. To do that, you can create a custom class that overrides the DoMultiSelect() method and raises a flag when the user changes the selection when the Shift key is pressed. 

public class MyNavigator : BaseGridNavigator
{
    int shiftDoubleSelectionCounter = 0;
    public override bool Select(GridViewRowInfo row, GridViewColumn column)
    {
        if (!this.IsShiftButtonPressed)
        {
            shiftDoubleSelectionCounter = 0;
        }
            
        return base.Select(row, column);
    }
    protected override bool DoMultiSelect(GridViewRowInfo oldRow, GridViewColumn oldColumn, GridViewRowInfo row, GridViewColumn column)
    {
        if(this.IsShiftButtonPressed)
        {
            shiftDoubleSelectionCounter++;
            if (shiftDoubleSelectionCounter % 2 == 0)
            {
                this.ClearSelection();
                this.EndSelection();
                var test = this.GridViewElement.Template.SelectedRows;
                row.IsSelected = true;
                shiftDoubleSelectionCounter = 0;
                return false;
            }
        }

        return base.DoMultiSelect(oldRow, oldColumn, row, column);
    }
}

public RadForm1()
{
    InitializeComponent();
    this.radGridViewMain.GridViewElement.Navigator = new MyNavigator();
}

You can find the test project attached to this reply. Keep in mind that this is a custom solution and it may not work in all scenarios as it is not supported out of the box by the control. 

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Park
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or