To reproduce:
1. Select multiple cells in RadVirtualGrid
2. Right-click one of the selected cells. The expected behavior is to open the context menu in order to allow copy operation and keep the selected cells. However, the obtained result is that the selected cells are cleared.
Workaround:
Me.RadVirtualGrid1.VirtualGridElement.InputBehavior = New CustoVirtualGridInputBehavior(Me.RadVirtualGrid1.VirtualGridElement)
AddHandler Me.RadVirtualGrid1.SelectionChanging, AddressOf SelectionChanging
Private Sub SelectionChanging(sender As Object, e As Telerik.WinControls.UI.VirtualGridSelectionChangingEventArgs)
If Me.RadVirtualGrid1.VirtualGridElement.Tag = "CancelSelectionChange" Then
e.Cancel = True
Me.RadVirtualGrid1.VirtualGridElement.Tag = Nothing
End If
End Sub
Public Class CustoVirtualGridInputBehavior
Inherits VirtualGridInputBehavior
Public Sub New(gridElement As RadVirtualGridElement)
MyBase.New(gridElement)
End Sub
Public Overrides Function HandleMouseDown(args As MouseEventArgs) As Boolean
If args.Button = MouseButtons.Right Then
Dim cell As VirtualGridCellElement = TryCast(Me.GridElement.ElementTree.GetElementAtPoint(args.Location), VirtualGridCellElement)
If cell IsNot Nothing AndAlso cell.IsSelected Then
Me.GridElement.Tag = "CancelSelectionChange"
End If
End If
Return MyBase.HandleMouseDown(args)
End Function
End Class