|
//First DataGrid
sfDataGrid.AutoGenerateColumns = false;
sfDataGrid.DataSource = new ViewModel().Orders;
sfDataGrid.Name = "FirstDataGrid";
sfDataGrid.CellButtonClick += SfDataGrid_CellButtonClick;
//Second DataGrid
var table = this.GetDataTable();
sfDataGrid1.Name = "SecondDataGrid";
sfDataGrid1.DataSource = table;
sfDataGrid1.CellButtonClick += SfDataGrid_CellButtonClick;
private void SfDataGrid_CellButtonClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellButtonClickEventArgs e)
{
//get the cellbutton clicke DataGrid
var dataGrid = e.Record.GetType().GetProperty("DataGrid", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(e.Record) as SfDataGrid;
//check the datagrid based on SfDataGrid Name property
if(dataGrid.Name == "FirstDataGrid")
{
MessageBox.Show(dataGrid.Name);
}
else if(dataGrid.Name == "SecondDataGrid")
{
MessageBox.Show(dataGrid.Name);
}
} |