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

Passing parameters to RecordContextMenu

Thread ID:





143672 Mar 31,2019 03:57 PM UTC Apr 1,2019 11:59 AM UTC WinForms 1
Tags: SfDataGrid
Asked On March 31, 2019 03:57 PM UTC

I am trying to use the sfDatagrid.Record contextMenu, but can't figure out how to add a function to the selected context menu. What I want is to pass the row index and column index into the Addcomment function, but am not sure what parameters should the RecordContextMenu take. Any help would be appreciated.

       ContextMenuStrip recordContextMenu = new ContextMenuStrip();
       recordContextMenu.Items.Add("Add Comment", null, AddComment);
       sfDataGrid4.RecordContextMenu = recordContextMenu;

        private void AddComment(int rowIndex, int colIndex)
            form2 f1 = new form2(columnIndex, ID);

Jagadeesan Pichaimuthu [Syncfusion]
Replied On April 1, 2019 11:59 AM UTC

Hi Julius,  

Thank you for contacting Synfusion Support. 

We have analyzed your query to pass row and column index in contextmenu function and you can achieve this by retrieving row and column index from the current cell by using the below code snippet. 

ContextMenuStrip recordContextMenu = new ContextMenuStrip(); 
recordContextMenu.Items.Add("Add Comment", null, AddComment); 
sfDataGrid4.RecordContextMenu = recordContextMenu; 
private void AddComment(object sender, EventArgs e) 
    var rowIndex = sfDataGrid4.CurrentCell.RowIndex; 
    var columnIndex = sfDataGrid4.CurrentCell.ColumnIndex;     
    form2 f1 = new form2(columnIndex, ID);  

Also please refer to the below UG link for more details on ContextMenu in SfDataGrid 

Please let us know, if you need any further assistance on this. 



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