Right Click Menu in C# 5

Best known as the Context Menu Strip in .Net Framework, it provides a convenient way to create the Right Click menu. Start off by dragging the tool named ContextMenuStrip in the Toolbox window, under the Menus & Toolbars tab. Works just like the Menu tool, Add & Delete items as you desire. Items include Textbox, Combobox or yet another Menu Item. 

For displaying the Menu, we have to simply check if the right mouse button was pressed. This can be done easily by creating the MouseClick event in the form's Designer.cs file. The MouseEventArgs contains a check to see if the right mouse button was pressed(or left, middle etc.).

The Show() method is a little tricky to use. When using this method, the first parameter is the location of the button relative to the X & Y coordinates that we supply next(the second & third arguments). The best method is to place an invisible control at the location (0,0) in the form. Then, the arguments to be passed are the e.X & e.Y in the Show() method. In short :


Please Note :
** Do not Copy & Paste code written here ; instead type it in your Development Environment
** Testing done in .Net Framework 4.5 but code should be very similar for previous versions of .Net
** All Program Codes written here are  100%  tested & running.
Custom Search