[Solved] GridView Rows Selection

1 Answer 38 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.

Park
Top achievements
Rank 1
commented on 11 Feb 2026, 01:34 AM

I've reviewed the project you provided. I've verified that it can be handled by inheriting from BaseNavigator.

However, what I want is that after selecting a row with Shift + drag,
when I start dragging from a different RowIndex, the area from the previous drag disappears.

Currently, the area selection is being re-selected from the starting point of the previous drag.

Select rows 1 to 8 by dragging them like this and If you want to drag from 7 to 8, of course it's Shift + drag.

From the point of MouseDown, the drag area is specified from the previously selected 1.

What I want is to not remember the information from the previous drag.

Dinko | Tech Support Engineer
Telerik team
commented on 11 Feb 2026, 12:00 PM

The start row position while holding the Shift key is not fully reset. To reset it, you can use the AnchoredPosition.RowPosition property. Here is the updated custom class:

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;
                row.IsCurrent = true;
                shiftDoubleSelectionCounter = 0;
                this.AnchoredPosition.RowPosition = this.Traverser.Position;
                return false;
            }
        }

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

I think now the Shift reset is working as expected.

Park
Top achievements
Rank 1
commented on 27 Feb 2026, 07:30 AM



protected override bool DoMultiSelect(GridViewRowInfo oldRow, GridViewColumn oldColumn, GridViewRowInfo row, GridViewColumn column)
{
    if (this.IsShiftButtonPressed)
    {
        this.ClearSelection();
        this.EndSelection();
    }

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

Thank you, Dinko.
The issue has been resolved using the code you provided above.

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