Completed
Last Updated: 28 Nov 2016 16:01 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 11 Nov 2016 10:28
Category: GridView
Type: Bug Report
1
FIX. RadGridView - starting selection from row header and moving the cursor should select all cells from the affected rows no matter the SelectionMode
To reproduce: populate a grid and enable multiple selection. Use cell selection. When you click the row header, the entire row (all cells from the row) is selected no matter the SelectionMode. However, if you start a selection from the row header and move the cursor, only the cells from the first column get selected. The attached gif file illustrates the behavior.  The expected behavior is that all cells from the affected columns should be selected when starting the selection from the row header.

Workaround:

Sub New()
    InitializeComponent()
    Me.RadGridView1.MultiSelect = True
    Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect

    AddHandler Me.RadGridView1.MouseDown, AddressOf GridMouseDown
    AddHandler Me.RadGridView1.MouseUp, AddressOf GridMouseUp
    AddHandler Me.RadGridView1.MouseMove, AddressOf GridMouseMove
End Sub

Dim isMouseDown = False
Dim startRow As GridViewRowInfo
Dim lastHoveredCell As GridCellElement
Private Sub GridMouseDown(sender As Object, e As MouseEventArgs)
    Dim cell As GridRowHeaderCellElement = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridRowHeaderCellElement)
    If cell IsNot Nothing Then
        isMouseDown = True
        startRow = cell.RowInfo
    End If
End Sub

Private Sub GridMouseUp(sender As Object, e As MouseEventArgs)
    isMouseDown = False
    startRow = Nothing
End Sub

Private Sub GridMouseMove(sender As Object, e As MouseEventArgs)
    If isMouseDown Then 
        Dim cellUnderMouse As GridCellElement = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridCellElement)
        If cellUnderMouse IsNot Nothing AndAlso Not cellUnderMouse.Equals(lastHoveredCell) Then
            lastHoveredCell = cellUnderMouse
            Me.RadGridView1.ClearSelection()
            Me.RadGridView1.SelectedCells.BeginUpdate()
            If startRow.Index > cellUnderMouse.RowInfo.Index Then
                For index = cellUnderMouse.RowInfo.Index To startRow.Index
                    Me.RadGridView1.Rows(index).IsSelected = True
                Next
            Else
                For index = startRow.Index To cellUnderMouse.RowInfo.Index
                    For Each cell As GridViewCellInfo In Me.RadGridView1.Rows(index).Cells
                        cell.IsSelected = True
                    Next
                Next
            End If
            Me.RadGridView1.SelectedCells.EndUpdate(True)
        End If
    End If
End Sub
0 comments