right click context menu for datagridview

You can use the CellMouseEnter and CellMouseLeave to track the row number that the mouse is currently hovering over. Then use a ContextMenu object to display you popup menu, customised for the current row. Here’s a quick and dirty example of what I mean… private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) … Read more

Making custom right-click context menus for my web-app

I know this question is very old, but just came up with the same problem and solved it myself, so I’m answering in case anyone finds this through google as I did. I based my solution on @Andrew’s one, but basically modified everything afterwards. EDIT: seeing how popular this has been lately, I decided to … Read more

How to add a custom right-click menu to a webpage?

Answering your question – use contextmenu event, like below: if (document.addEventListener) { document.addEventListener(‘contextmenu’, function(e) { alert(“You’ve tried to open context menu”); //here you draw your own menu e.preventDefault(); }, false); } else { document.attachEvent(‘oncontextmenu’, function() { alert(“You’ve tried to open context menu”); window.event.returnValue = false; }); } <body> Lorem ipsum… </body> But you should ask … Read more

How to distinguish between left and right mouse click with jQuery

As of jQuery version 1.1.3, event.which normalizes event.keyCode and event.charCode so you don’t have to worry about browser compatibility issues. Documentation on event.which event.which will give 1, 2 or 3 for left, middle and right mouse buttons respectively so: $(‘#element’).mousedown(function(event) { switch (event.which) { case 1: alert(‘Left Mouse button pressed.’); break; case 2: alert(‘Middle Mouse … Read more