Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable double click on winform button?

Tags:

c#

winforms

I don't want to allow user to double click on my button. On the first click it should be disabled and once my code is executed, i should enable the button. How to do ?

like image 369
Anuya Avatar asked Dec 07 '22 03:12

Anuya


1 Answers

You can use the Enabled property. Register an OnClick event handler and set Enabled to false as the first thing. Then start you computation and restore Enabled to true, when you are finished. If the computation takes long to complete, you should start a second thread. In that case, you may need to use Invoke method to re-enable the button.

like image 177
kgiannakakis Avatar answered Jan 07 '23 21:01

kgiannakakis