Create Context Menu on Windows Forms Form with C#

The amazing thing in this trick is, there is no need for any additional coding. 

So, let’s begin with the topic.

Step 1

Open Visual Studio (here I used Visual Studio 2010 Express).

microsoftvisual C sharp

Step 2

Go to File Menu and click on New Project (alternatively we can use the shortcut key Ctrl + Shift + N).

new project

After clicking on New Project, our screen will look as shown in the following image.

console application

Step 3

Here we need to select the "Windows Forms Application" template, then we can also rename the project (I renamed it to RightClickMenuExample as shown in the following image). 

After selecting the "Windows Forms Application" template click on the OK button that is showing at the bottom-right of the image.

windows form application

Now our Windows Forms application is ready. Now to add the required controls so we need to move towards Step 4. 

Step 4

You will be surprised that we need only 1 (single) control to create the Context Menu on the Windows Forms form. Here we need to add a "ContextMenuStrip" control. Now our project will look such as shown in the following image.

add ContextMenuStrip

Step 5

Select the “ContextMenuStrip” control and start adding the name of menus, for example I added menus like Menu1, Menu2 and then added SubMenu1, SubMenu2 etc.


Coding / Setting Part

As I said, there is no need for more coding but we need to do a little setting to get the Context Menu appear on the Windows application form. We will learn this is in Step 5.

Step 6

After adding the name of the menu on you application, right-click on the Windows Forms application and go to the properties.


Select "ContextMenuStrip" and change it to ContextMenuStrip1 from (none).


Here we have done our project. To check the Context Menu, run the project (or press the function key F5) and right-click on the form, the Context Menu will appear on the form as shown in the following image.

Right Click Menu

In the next article, we will learn something new. Thank you.