Click here to Skip to main content
15,905,914 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to know how can i make double right click for button C#
and in the same time i make another right click for this button event
Posted
Updated 14-Jun-12 8:52am
v2

1 solution

There are events for each of these options on the button itself. You just need to add a handler to capture the event. Here is a tutorial on how to capture double-clicks in C#:

http://msdn.microsoft.com/en-us/library/ms171543(v=vs.80).aspx[^]

The right-click would be the same thing. Just add a handler for the right-click event and wire it up.

Here is a tutorial that includes adding event handlers to a button:

http://msdn.microsoft.com/en-us/library/dd492131.aspx[^]

Since you want to capture a double right-click event (which there isn't one natively), you could capture the right-click event and check to see if the event gets fired twice in a certain period of time. If not, make it a right-click event. If it does, don't run the right-click code but run the double-right-click code instead. This means you will need to delay the processing of the right-click event for a short period of time (less than a second for sure). If you wanted to make things easier and it was ok to fire both the right-click event and the double-right-click event, you could let the first one fire and then the second time, you could check to see if the event just fired. If so, you could kick off the double-right-click code instead.
 
Share this answer
 
v2
Comments
Manas Bhardwaj 15-Jun-12 6:55am    
Good answer +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900