# Adding Custom Context Menu to a Component

Learn how to create and add a context menu to the FpSpread component in this comprehensive guide. Discover the step-by-step process and examples for implementing a context menu in your application.

## Content

You can create a context menu and add it to the [ContextMenu](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) property of the FpSpread component (which is inherited from the System.Windows.Forms.Control). The component automatically displays this menu of context-specific menu options when you right click on the component. A context menu is also known as a shortcut menu. For more information, refer to the [Microsoft .NET documentation](https://learn.microsoft.com/en-us/dotnet/) about context menu (or shortcut menu). The figure shows a context menu with two choices. The code for this figure is shown in the example.
![Context Menu Example](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/contextmenu.png)
The scroll bars have, by default, a context menu of their own.

## Using Code

1. Add a context menu using the **ContextMenu** property.
2. Define the menu items.

## Example

This example creates a context menu.

```csharp
ContextMenu custommenu = new ContextMenu();
custommenu.MenuItems.Add("&Table");
custommenu.MenuItems.Add("&Color", new EventHandler(ContextMenu_Color));
fpSpread1.ContextMenu = custommenu;

private void ContextMenu_Color(object sender, System.EventArgs e)
{
    MessageBox.Show("You chose color.");
}
```

```vbnet
Dim custommenu As New ContextMenu
custommenu.MenuItems.Add("&Table")
custommenu.MenuItems.Add("&Color", New EventHandler(AddressOf ContextMenu_Color))
FpSpread1.ContextMenu = custommenu

Private Sub ContextMenu_Color(ByVal sender As Object, ByVal e As System.EventArgs)
     MsgBox("You chose color.")
End Sub
```

## See Also

[Displaying Context Menu at Runtime](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-displaycontextmenu)
[Customizing Interaction in Cells](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell)
[Using Edit Mode and Focus](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cell-focus)
[Customizing User Selection and Deselection of Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-interactselection)
[Using Drag Operations to Fill Cells](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cell-dragops)
[Using Validation](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cellvalid)
[Using Visible Indicators in the Cell](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cell-indicators)
[Customizing Undo and Redo Actions](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-undoredo)
[Customizing Interaction Based on Events](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cntrlevents)
[Using Double Click to Fill Cells](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cell-clicktofill)