Completed
Last Updated: 18 Sep 2015 13:24 by ADMIN
ADMIN
Dimitar
Created on: 14 Jul 2015 15:16
Category: GridView
Type: Bug Report
1
FIX. RadGridView - when multiselect is enabled and several cells are quickly deselected, the selection is not correct
To reproduce:
radGridView1.DataSource = GetTable();
radGridView1.MultiSelect = true;
radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;

Then just select and deselect several cells without releasing the mouse button.

Workaround:
void radGridView1_MouseUp(object sender, MouseEventArgs e)
{
    int endIndexCol = -1;
    int endIndexRow = -1;
     GridDataCellElement curentCell = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement;
     if (curentCell != null)
     {
         endIndexCol = curentCell.ColumnInfo.Index;
         endIndexRow = curentCell.RowInfo.Index;
     }
    if (endIndexCol < startIndexCol)
    {
        int temp = endIndexCol;
        endIndexCol = startIndexCol;
        startIndexCol = temp;
    }
    if (endIndexRow < startIndexRow)
    {
        int temp = endIndexRow;
        endIndexRow = startIndexRow;
        startIndexRow = temp;
    }
    
    foreach (GridViewCellInfo cell in radGridView1.SelectedCells.ToList())
    {
        if (cell.RowInfo.Index < startIndexRow || cell.RowInfo.Index > endIndexRow)
        {
            cell.IsSelected = false;
        }
        if (cell.ColumnInfo.Index < startIndexCol || cell.ColumnInfo.Index > endIndexCol)
        {
            cell.IsSelected = false;
        }
    }
}

int startIndexCol = -1 ;
int startIndexRow = -1;

void radGridView1_MouseDown(object sender, MouseEventArgs e)
{
    GridDataCellElement curentCell = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement;
    if (curentCell != null)
    {
        startIndexCol = curentCell.ColumnInfo.Index;
        startIndexRow = curentCell.RowInfo.Index;
    }

}

0 comments