Completed
Last Updated: 19 Jun 2017 12:06 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 25 Jan 2017 09:34
Category: GridView
Type: Bug Report
1
FIX. RadGridView - multiple cell selection is cleared when clicking a cell twice while pressing Shift
To reproduce:

this.Controls.Add(this.radGridView1);
this.radScheduler1.Dock = DockStyle.Fill;

List<GridRec> records = new List<GridRec>();
GridRec rec = new GridRec();
rec.Column1 = "1";
rec.Column2 = "2";
rec.Column3 = "3";
rec.Column4 = "4";
rec.Column5 = "5";
rec.Column6 = "6";
rec.Column7 = "7";
rec.Column8 = "8";
rec.Column9 = "9";

for (int i = 0; i < 20; ++i)
{
    records.Add(rec.Clone());
}

radGridView1.DataSource = records;
this.radGridView1.MultiSelect = true;
this.radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
this.radGridView1.Dock = DockStyle.Fill;

public class GridRec
{
    public GridRec Clone()
    {
        return this.MemberwiseClone() as GridRec;
    }

    public string Column1 { get; set; }

    public string Column2 { get; set; }

    public string Column3 { get; set; }
    
    public string Column4 { get; set; }

    public string Column5 { get; set; }

    public string Column6 { get; set; }

    public string Column7 { get; set; }

    public string Column8 { get; set; }

    public string Column9 { get; set; }
}

If you run the application, it starts with the upper-left most cell selected.  Now, while holding down the Shift key, left-click on the cell in the 5th column of the 5th row (cell 5:5).  Note all 25 cells are selected as expected.  Now, while still holding Shift, left-click again on cell 5:5 and note the selection is cleared.
Now, while still holding Shift, click on cell 4:4 (4th column, 4th row).  Note how the selected range is now cells 1:1 through 4:4.  And while still holding Shift, if you click on 4:4 yet again, the selection is cleared.

Workaround: 

private void radGridView1_SelectionChanging(object sender, Telerik.WinControls.UI.GridViewSelectionCancelEventArgs e)
{
    if (e.ColumnStartIndex == e.ColumnEndIndex && Control.ModifierKeys == Keys.Shift)
    {
        e.Cancel = true;
    }
}
0 comments