Hi Marco Del Frate,
We
have analyzed your query. In Spreadsheet, we have both TabItem Context Menu and Cell
Context Menu supports. However, you didn't
specify a particular context menu. We have provided a solution for both
scenarios.
In
the case of customizing the Cell Context Menu of SfSpreadsheet, you can use the
CellContextMenuOpening event of the SpreadsheetGrid. For the TabItem Context
Menu, you can customize it by setting the IsCustomTabItemContextMenuEnabled
property to true and adding your customized menu items. In both approaches, you
can achieve the operation of added menu items in the click event by using the
declared added menu items variable.
UG Link : https://help.syncfusion.com/wpf/spreadsheet/interactive-features#tabitem-context-menu
https://help.syncfusion.com/wpf/spreadsheet/interactive-features#cell-context-menu
Code Snippet for
Cell Context Menu:
|
private void
Spreadsheet_WorkbookLoaded(object sender, WorkbookLoadedEventArgs args)
{
spreadsheet.ActiveGrid.CellContextMenuOpening +=
ActiveGrid_CellContextMenuOpening;
}
private void
ActiveGrid_CellContextMenuOpening(object sender,
Syncfusion.UI.Xaml.CellGrid.Helpers.CellContextMenuOpeningEventArgs e)
{
MenuItem deleteRow = new MenuItem();
deleteRow.Header = "DeleteRow";
deleteRow.Click += DeleteRow_Click;
spreadsheet.ActiveGrid.CellContextMenu.Items.Add(deleteRow);
}
private void
DeleteRow_Click(object sender, RoutedEventArgs
e)
{
MessageBox.Show("Delete Opeartion
in CellContextMenu");
}
|
Code Snippet for
Tab Item Context Menu:
|
spreadsheet.IsCustomTabItemContextMenuEnabled
= true;
spreadsheet.TabItemContextMenu
= CustomTabItemContextMenu();
//Custom
TabItem ContextMenu
public
ContextMenu CustomTabItemContextMenu()
{
var contextMenu = new ContextMenu();
var insertRow = new MenuItem() { Header = "InsertRow"
};
insertRow.Click
+= insertRow_Click;
contextMenu.Items.Add(insertRow);
return contextMenu;
}
|
Image Reference: