 In many of your C# / VB / .Net projects, you'll sooner or later have to dynamically create a context menu populated by different values. Your problem is to determine on which item users click. The MouseClick event does let you retrieve the click's coordinates, from which you could determine the event source, but there's an easier way. The context menu in the screenshot is programmatically created (at runtime), and is populated by a list of files - clicking on a menu item would (for example) open the file.
 In many of your C# / VB / .Net projects, you'll sooner or later have to dynamically create a context menu populated by different values. Your problem is to determine on which item users click. The MouseClick event does let you retrieve the click's coordinates, from which you could determine the event source, but there's an easier way. The context menu in the screenshot is programmatically created (at runtime), and is populated by a list of files - clicking on a menu item would (for example) open the file. Once you've dropped your context menu in your Visual Studio project, click on it, view its properties, and double-click on the ItemsClicked event to generate a handler. The "ToolStripItemClickedEventArgs e" (by default) will let you get information about the item clicked.
 Once you've dropped your context menu in your Visual Studio project, click on it, view its properties, and double-click on the ItemsClicked event to generate a handler. The "ToolStripItemClickedEventArgs e" (by default) will let you get information about the item clicked.private void ContextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {
    MessageBox.Show( ( (ToolStripMenuItem)e.ClickedItem ).ToString() );
} Clicking on the menu, we now get the entire item's text as a usable string. If you assigned accelerator keys (ampersand symbol "&"), remember that they'll show up in the menu text as well.  
 Tip - you can also get the menu item's content through the Text property: MessageBox.Show( ((ToolStripMenuItem)e.ClickedItem).Text );