Right click to select a row in a Datagridview and show a menu to delete it

I finally solved it: In Visual Studio, create a ContextMenuStrip with an item called “DeleteRow” Then at the DataGridView link the ContextMenuStrip Using the code below helped me getting it work. this.MyDataGridView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MyDataGridView_MouseDown); this.DeleteRow.Click += new System.EventHandler(this.DeleteRow_Click); Here is the cool part private void MyDataGridView_MouseDown(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Right) { … Read more

Right Clicking on JButton

For Minesweeper game you have look for 1) JToggleButton 2) add Icon to JToggleButton methods JToggleButton#setIcon(); JToggleButton#setSelectedIcon(); JToggleButton#setDisabledIcon(); 3) add MouseListener to JToggleButton 4) override mouseClicked with method SwingUtilities.isRightMouseButton() inside result could be from code import java.awt.Insets; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.Icon; import javax.swing.JFrame; import javax.swing.JToggleButton; import javax.swing.SwingUtilities; import javax.swing.UIManager; public class MyToggleButton extends … Read more

How to pass in multiple file/folder paths via a right-click event (verb) to an executable?

If you’re looking for a quick and dirty workaround, you can create a shortcut to your executable in ‘%AppData%\Microsoft\Windows\SendTo’ Now you can select a bunch of files, right click, select Send To, and your application. This will pass all the selected files as individual command line options to one instance of your application… keep in … Read more

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

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