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

Detecting cell right mouse click on sfdatagrid

Thread ID:





150311 Jan 1,2020 03:30 AM UTC Jan 3,2020 08:39 AM UTC WinForms 5
Tags: SfDataGrid
Tom Krieg
Asked On January 1, 2020 03:30 AM UTC

How can I detect a RIGHT mouseclick on a cell of sfdatagrid, and get the row and column number?

Saravanan Ayyanar [Syncfusion]
Replied On January 2, 2020 01:01 PM UTC

Hi Tom,  
Thanks for using Syncfusion controls.  
You can able to detect the right mouse click of GridCell by using SfDataGrid.CellClick event. Please refer the below code snippet.  
this.sfDataGrid1.CellClick += SfDataGrid1_CellClick;  
private void SfDataGrid1_CellClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e)  
        var rowColumnIndex =this.sfDataGrid1.TableControl.PointToCellRowColumnIndex(e.MouseEventArgs.Location);  
Please find the sample below. 
Sample Link:  
Please let us know, if you require further assistance on this.  
Saravanan A.  

Tom Krieg
Replied On January 3, 2020 04:11 AM UTC

Thanks for your reply. I am using Visual Basic and have the following code (derived from the C# code you provided and where gridReceipts is a sfdatagrid).

    Private Sub gridReceipts_CellClick(sender As Object, e As CellClickEventArgs) Handles gridReceipts.CellClick
        If e.MouseEventArgs.Button = MouseButtons.Right Then
            Dim rowColumnIndex = gridReceipts.TableControl.PointToCellRowColumnIndex(e.MouseEventArgs.Location)
        End If
    End Sub

I get the following error:  Option Strict On requires all variable declarations to have an 'As' clause

I cannot use the type 'RowColumnIndex' (as specified in your example for sfdatagrid online help) and if I do the compiler throws an error. (Type 'RowColumnIndex' is not defined.

Could you please advise what type I should use in the 'as' clause?

I have references to

Saravanan Ayyanar [Syncfusion]
Replied On January 3, 2020 07:37 AM UTC

Hi Tom,  
Thank you for update. 
We have analyzed your reported issue with provided code example. But the issue is not reproduced and  the sample is executed without any compiler error at our end. And you can use the type RowColumnIndex from the Syncfusion.WinForms.GridCommon.ScrollAxis namespace.  
Sample Link:  
If still you are facing the same issue, please revert us with more details on replication procedure/video illustration of the issue. Also if possible, please revert us with the modified sample. It will helps us to investigate further and provide earlier prompt solution.  
Saravanan A.  

Tom Krieg
Replied On January 3, 2020 08:37 AM UTC

Once I referenced Syncfusion.WinForms.GridCommon.ScrollAxis then the errors disappeared and the function works as documented. Thanks.

Farjana Parveen Ayubb [Syncfusion]
Replied On January 3, 2020 08:39 AM UTC

Hi Tom, 
Thanks for the update. 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
Farjana Parveen A 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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
Live Chat Icon