Last Updated: 28 Nov 2016 16:01 by ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 11 Nov 2016 10:28
Category: GridView
Type: Bug Report
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.


Sub New()
    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
            If startRow.Index > cellUnderMouse.RowInfo.Index Then
                For index = cellUnderMouse.RowInfo.Index To startRow.Index
                    Me.RadGridView1.Rows(index).IsSelected = True
                For index = startRow.Index To cellUnderMouse.RowInfo.Index
                    For Each cell As GridViewCellInfo In Me.RadGridView1.Rows(index).Cells
                        cell.IsSelected = True
            End If
        End If
    End If
End Sub
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)