Get row values datagrid via right click

How do i get the row values of sfdatagrid through right click when there are groupings on it?

3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team June 8, 2021 11:44 AM UTC

Hi Olayinka,

Thank you for contacting Syncfusion Support.

Your requirement can be achieved by customizing the SfDataGrid.CellClick event in SfDataGrid. Please refer the below code snippet, 
sfDataGrid1.CellClick += SfDataGrid1_CellClick;

private void SfDataGrid1_CellClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e) 
{ 
            //check the mouse right click 
            if (e.MouseEventArgs.Button == MouseButtons.Right) 
            { 
                //only allow thw record row in SfDataGrid 
                if (e.DataRow.RowType == Syncfusion.WinForms.DataGrid.Enums.RowType.DefaultRow) 
                { 
                    //Observable Collection need to type cast the Underline business object 
                    //var record = (e.DataRow.RowData as OrderInfo); 
                    //MessageBox.Show(" OrderID " + record.OrderID + " CustomerID " + record.CustomerID + " CustomerName " + record.CustomerName + " Country " + record.Country + " ShipCity " + record.ShipCity + " IsShipped " + record.IsShipped); 
 
                   ////DataTable collection get the rowdata 
                    var record = (e.DataRow.RowData as DataRowView); 
                    MessageBox.Show(" OrderID " + record.Row[0] + " CustomerID " + record.Row[1] + " CustomerName " + record.Row[2] + " Country " + record.Row[3] + " ShipCity " + record.Row[4]); 
                } 
            } 
}   
For more information related to CellClick event, please refer the below user guide documentation,

UG Link:
https://help.syncfusion.com/windowsforms/datagrid/selection#getting-the-cell-value-by-using-cell-click-event 

Please let us know if you have any concerns in this.

Regards,
Vijayarasan S 


Marked as answer

OL Olayinka June 9, 2021 06:57 PM UTC

Thanks a lot 👍


VS Vijayarasan Sivanandham Syncfusion Team June 10, 2021 05:57 AM UTC

Hi Olayinka

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😊

Regards, 
Vijayarasan S 


Loader.
Up arrow icon