Add or Remove Context Menu Items in GridWeb

Add Context Menu Item using ASP.NET Markup

The following ASP.NET markup adds a context menu item in GridWeb.

Here is the full ASP.NET markup that creates a GridWeb with the above context menu item. Please note the OnCustomCommand="GridWeb1_CustomCommand" attribute. It is the event handler name that will be called when your context menu item is clicked.

This is how the context menu item looks after being added using the above ASP.NET markup.

todo:image_alt_text

This is the event handler code which is executed when the context menu item is clicked. The code first checks the command name; if it matches our command, it adds text in cell A1 of the active GridWeb worksheet and sets the first column width to 40 units to make the text visible.

This is how the GridWeb looks when you click on the context menu item.

todo:image_alt_text

Add Context Menu Items in Aspose.Cells.GridWeb using Code

This code shows how to add a context menu item inside a GridWeb using code.

Remove Context Menu Items in Aspose.Cells.GridWeb using Code

This code shows how to remove a context menu item using the CustomCommandButtons.Remove() and CustomCommandButtons.RemoveAt() methods.