We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create a customized cell context menu of WinForms Spreadsheet (SfSpreadsheet)?

Platform: WinForms |
Control: Spreadsheet
Tags: context-menu

Customize the cell context menu

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 Spreadsheet.


For example, create a custom context menu items such as Insert Row, Insert Column, Delete Row and Delete Column respectively.


public ContextMenuStrip CustomContextmenu()
    var contextMenu = new ContextMenuStrip();
    contextMenu.BackColor = Color.White;
    var Insertrow = new ToolStripMenuItem() { Text = "InsertRow", Height = 26 };
    Insertrow.BackColor = Color.White;
    Insertrow.Click += Insertrow_Click;
    var Deleterow = new ToolStripMenuItem() { Text = "DeleteRow", Height = 26 };
    Deleterow.BackColor = Color.White;
    Deleterow.Click += Deleterow_Click;
    var Insertcolumn = new ToolStripMenuItem() { Text = "Insertcolumn", Height = 26 };
    Insertcolumn.BackColor = Color.White;
    Insertcolumn.Click += Insertcolumn_Click;
    var Deletecolumn = new ToolStripMenuItem() { Text = "Deletecolumn", Height = 26 };
    Deletecolumn.BackColor = Color.White;
    Deletecolumn.Click += Deletecolumn_Click;
    return contextMenu;

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


void spreadsheet_WorkbookLoaded(object sender, WorkbookLoadedEventArgs args)
   spreadsheet.ActiveGrid.CellContextMenuOpening += ActiveGrid_CellContextMenuOpening;


private void ActiveGrid_CellContextMenuOpening(object sender, Syncfusion.Windows.Forms.CellGrid.Helpers.CellContextMenuOpeningEventArgs e)
   e.CellContextMenu = CustomContextmenu();

The following screenshot illustrates the Spreadsheet after create cell context menu  

Show the customize context menu of spreadsheet

Sample: WinForms

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile