Articles in this section
Category / Section

How to Prevent Selection while Pressing Right-Click in WPF DataGrid?

2 mins read

You can prevent selection when right clicking in WPF DataGrid (SfDataGrid) by customizing the GridSelectionController and overriding the ProcessPointerPressed method.

Refer the below code example in which the row selection for DataGrid is skipped when clicking right mouse button.

protected override void ProcessPointerPressed(MouseButtonEventArgs args, RowColumnIndex rowColumnIndex)
{
    if (args.ChangedButton == MouseButton.Right)
    {
        args.Handled = true;
    }
    else
    {
        base.ProcessPointerPressed(args, rowColumnIndex);
    }
}


Conclusion

I hope you enjoyed learning about how to prevent selection while pressing right-click in DataGrid.

You can refer to our WPF DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF DataGrid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied