Category / Section
How to prevent row selection on right click of the mouse?
1 min read
In GridDataBoundGrid, you can select the rows on right click of the mouse . To prevent the row selection on right click of the mouse , you can use the SelectionChanging event.
The following code example demonstrates how to disable the row selection on right click of the mouse
C#
// Hooking SelectionChanging event. this.gridDataBoundGrid1.Model.SelectionChanging += new GridSelectionChangingEventHandler(Model_SelectionChanging); void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e) { // Checking mouse right button. if (e.Reason == Syncfusion.Windows.Forms.Grid.GridSelectionReason.MouseDown && e.ClickRange.RangeType == Syncfusion.Windows.Forms.Grid.GridRangeInfoType.Rows && Control.MouseButtons == System.Windows.Forms.MouseButtons.Right) { this.gridDataBoundGrid1.Model.Selections.Clear(); //Disabling selection on mouse right click. e.Cancel = true; } }
VB
' Hooking SelectionChanging event. Private Me.gridDataBoundGrid1.Model.SelectionChanging += New GridSelectionChangingEventHandler(AddressOf Model_SelectionChanging) Private Sub Model_SelectionChanging(ByVal sender As Object, ByVal e As GridSelectionChangingEventArgs) ' Checking mouse right button. If e.Reason = Syncfusion.Windows.Forms.Grid.GridSelectionReason.MouseDown AndAlso e.ClickRange.RangeType = Syncfusion.Windows.Forms.Grid.GridRangeInfoType.Rows AndAlso Control.MouseButtons = System.Windows.Forms.MouseButtons.Right Then Me.gridDataBoundGrid1.Model.Selections.Clear() 'Disabling selection on mouse right click. e.Cancel = True End If End Sub
Sample Links