Articles in this section
Category / Section

How to create a customized cell context menu of UWP SfSpreadsheet?

4 mins read

UWP Spreadsheet provides support to customize the cell context menu. User can add their own custom menu items and add this to the cell context menu of SfSpreadsheet.

 

For example

 

Create a custom context menu items such as Insert Row, Insert Column, Delete Row and Delete Column respectively.

 

C#:

public ContextMenu CustomContextmenu()
{
    var contextMenu = new ContextMenu();
 
//MENU1
    var Insertrow = new MenuFlyoutItem() {Text = "InsertRow", Height = 50 };
    Insertrow.BorderThickness = new Thickness(0);
    Insertrow.Click += Insertrow_Click;
 
//MENU2
    var Deleterow = new MenuFlyoutItem() { Text = "DeleteRow", Height = 50 };
    Deleterow.BorderThickness = new Thickness(0);
    Deleterow.Click += Deleterow_Click;
 
//MENU3
    var Insertcolumn = new MenuFlyoutItem() { Text = "Insertcolumn", Height = 50 };
     Insertcolumn.BorderThickness = new Thickness(0);
     Insertcolumn.Click += Insertcolumn_Click;
 
//MENU4
    var Deletecolumn = new MenuFlyoutItem() { Text = "Deletecolumn", Height = 50 };
    Deletecolumn.BorderThickness = new Thickness(0);
    Deletecolumn.Click += Deletecolumn_Click;
 
    contextMenu.Items.Add(Insertrow);
    contextMenu.Items.Add(Deleterow);
    contextMenu.Items.Add(Insertcolumn);
    contextMenu.Items.Add(Deletecolumn);
 
return contextMenu;
}

 

 

Now set this function CustomContextmenu to the CellContextMenu property of Active SpreadsheetGrid in the WorkbookLoaded event of SfSpreadsheet

 

C#:

void spreadsheet_WorkbookLoaded(object sender, WorkbookLoadedEventArgs args)
{
   spreadsheet.ActiveGrid.CellContextMenu = CustomContextmenu();
}

 

The following screenshot illustrates the SfSpreadsheet after create cell context menu

 

Sample link:

 

UWP

Conclusion

I hope you enjoyed learning about how to create a customized cell context menu of UWP Spreadsheet.

You can refer to our UWP Spreadsheet feature tour page to know about its other groundbreaking feature representations. You can also explore our UWP Spreadsheet documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied