We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent row selection on right click of the mouse?

Platform: WinForms |
Control: GridDataBoundGrid(Classic) |
Published Date: April 19, 2015 |
Last Revised Date: July 27, 2021
Tags: selection

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

RowSelection_C#

RowSelection_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile