In this blog I am trying to explain the how to make a custom right click in C#.

When I right click on a winform in C# then don’t have any menu popup will show if we want to add a right click popup menu the use the ContextStripMenu.

Implement ContextStripMenu in my demo

  1.   Open the VS 2010 and create a new project.

  2.    Give the appropriate name of your demo project.

  3.    By default show a Form1.

  4.  Drag and drop the ContextStripMenu from toolbox.

  5.   Then Right click on Form1 and select the ContextStripMenu property and select your ContextStripMenu which drag and drop on editor.

Make custom right click on a winform in C#

  6.  Click on the contextMenuStrip1 to show on the form.

Make custom right click on a winform in C#

  7.    Double click on the refresh and exit to get it events.

 8.   Write the this.Refresh() in refresh sub menu event below is example:


private void showToolStripMenuItem_Click(object sender, EventArgs e)

{
      this.Refresh();
}

  <![if !supportLists]> 9.  <![endif]> Write the this.Close() in Exit sub menu event below is example:



private void exitToolStripMenuItem_Click(object sender, EventArgs e)

{
      this.Close();
}       
Output:

Make custom right click on a winform in C#

  Modified On Nov-29-2017 12:32:34 PM

Leave Comment