How to create a custom double-click event for a button

I am developing C # in the .NET Framework. I already have an event on Button that happens with one click. I also want to have an event in Double Click for the same button.

How to create a Double click event on a button? I tried with this, but it does not work:

this.SetStyle(ControlStyles.StandardDoubleClick, true); this.button1.DoubleClick += new System.EventHandler(button1_DoubleClick); private void button1_DoubleClick(object sender, EventArgs e) { MessageBox.Show("You are in the Button.DoubleClick event."); } 
+4
source share
1 answer

The Button control (assuming you are in the winforms application) does not support double-clicking as a native event. You will need to create your own control, perhaps by inheriting with the button the provided frame and listening for two clicks for the appropriate time before triggering the DoubleClick event.

+3
source

All Articles