Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Right Click Events
 

Right Click Events

Hi

All i want have a Right click on my forms and want to add some functions and menu ..Please any ideas of help...


Thanks
Avinash
Avinash Desai  Friday, June 13, 2008 10:42 AM

you can capture the "mouseup" of your form. this event is already predefined.

then you can capture the MouseEventArgs using which you can determine whether "right" or "left" is clicked.

then you can proceed to put your logic here.

OR

add a contextmenu to your form.

hope this helps

nhd  Friday, June 13, 2008 2:04 PM

you can capture the "mouseup" of your form. this event is already predefined.

then you can capture the MouseEventArgs using which you can determine whether "right" or "left" is clicked.

then you can proceed to put your logic here.

OR

add a contextmenu to your form.

hope this helps

nhd  Friday, June 13, 2008 2:04 PM

I would like to do this too but MouseUp is there but I don't know what it is how do I determine witch button was clicked?

this answer was not complete enough for me (thank you)

Randy AC7NJ

ac7nj  Wednesday, October 08, 2008 7:42 PM
in mousedown eventhandler method add this line

If e.Button = Buttons.Right


EndIf

where e is the object of mouseeventargs class passed as parameter to the mousedown eventhandler method.

Asgar
  • Proposed As Answer by_asgar Thursday, January 01, 2009 11:57 AM
  •  
_asgar  Thursday, January 01, 2009 11:54 AM

Hi Avinash,

To enable right click event on a form, we need to add the "ContextMenuStrip" to the form. Once you have added the ContextMenuStrip to the form you can find it on top of the Form in design view. You just click on it andtype the desired items to be displayed when clicking right mouse button.
For example, if you want to add Open and Close on RightClick event, you need to do the following.

1. Drag and Drop the ContextMenuStrip from the ToolBox into the Form.
2. You can find the ContextMenuStrip at the bottom of the form. Just choose that control. Once you have selected that control, you can find the ContextMenuStrip on top of the Form in design view. (By default, ContextMenuStrip will not be shown on the form. It will show only if you select the control in the bottom bar).
3. You can find "Type Here" in the selected ContextMenuStrip. Just type "Open". It will automatically add the next item. Just type "Close" in the subsequent menu item.

This is how you need to add a ContextMenuStrip for a form. Please follow the following links for better understanding of how to use the control.

http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip.aspx

http://dotnetperls.com/Content/ContextMenuStrip-Example.aspx



-- Chandramohan.P

Chandramohan Palaniswamy  Monday, May 11, 2009 11:17 AM

You can use google to search for other answers

Custom Search

More Threads

• Server source code
• Keyword is "mari"
• Pocket TaskVision in VB.NET
• how come <i>Microsoft.ApplicationBlocks.Data</i> does not included in the C# project?
• Animal Farm?
• ??record video stream??
• No Animals teleport to my machine.
• SQLHelper.ExecuteReader error.
• Error - A Version of the Terrarium is already running - NOT
• Remote server unreachable error message