In my OnCellClick method, how can I get the name of the cell's datagrid. Presumably this can be derived from the event arguments (e), but I can't figure out how to get there.
I have multiple grids using the same onclick actions and I want to put the actions into a single method (with if/else logic) rather than creating a separate method for each grid.
I assume whatever solution you recommend will also work in my QueryRowStyle and QueryCellStyle events?
I am using C#.
Thank you.
|
private void SfDataGrid1_CellClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e)
{
if((sender as SfDataGrid).Name =="sfDataGrid1")
{
}
} |
This works well. Thank you very much!
Is there a way to let the same approach work the "CellButtonClickEventArgs" event as well?
For instance:
Hi Alison Tan,
You can achieve your requirement to get the SfDataGrid’s Name by using the CellButtonClickEventArgs shown below,
|
this.sfDataGrid1.CellButtonClick += OnCellButtonClick; { SfDataGrid datagrid = ((e.Record as Syncfusion.WinForms.DataGrid.DataRow).GetType().GetProperty("DataGrid", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(e.Record as Syncfusion.WinForms.DataGrid.DataRow) as SfDataGrid); if (datagrid.Name == "sfDataGrid1") {
} } |
We have prepared the sample based on your scenario. Please have a look at this and revert us if you need further assistance with this.
Regards,
Dhanasekar M.
If this post is helpful, please consider Accepting it as the solution so that
other members can locate it more quickly.