How to stop double click event in datagridview view?

I have a datagridview in which one of the columns is a checkbox. I am handling the CellContentClick event to update information each time a user checks or deselects one of these checkboxes. It works great. My problem is that when I double-click the checkbox, CellContentClick is called, and then CellContentDoubleClick . I want to cancel the call to CellContentDoubleClick . Is there any way to do this?

+6
source share
3 answers

You can remove the event handler from the datagrid.

EventHandler eventHandler = new EventHandler(YourdataGridview_CellContentDoubleClick); YourdataGridview.CellContentDoubleClick -= eventHandler; 
+1
source

You can create your own class that inherits from the DataGridView and override the method that raises the event so that it does not raise.

 public class MyDataGridView : DataGridView { protected override viod OnCellContentDoubleClick( DataGridViewCellEventArgs e) { // by having no code here and not // calling base.OnCellContentDoubleClick(e); // you prevent the event being raised } } 

See http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.oncellcontentdoubleclick.aspx

0
source

How about this:

 public class MyDataGridView : DataGridView { protected override void OnCellContentDoubleClick(DataGridViewCellEventArgs e) { base.OnCellContentClick(e); } } 
0
source

Source: https://habr.com/ru/post/907724/


All Articles