Computerman1597
Computerman1597

Reputation: 224

Run Action Upon Mouse Click and Mouse Release

I am working on a Windows Form C# project that requires running code when a user clicks down on a button, then waiting, and running a different set of code when the user then releases the mouse button. I have tried Button1.MouseDown and MouseUp as something that was suggested when I did a search for this information, but neither of these worked.

Does anyone know how to do this?

Thanks.

Upvotes: 0

Views: 725

Answers (1)

Pichu
Pichu

Reputation: 275

In visual studios, try clicking on the button and in properties, view the "Events" menu. You may have to scroll down and find Events "MouseDown" and Events "MouseUp".

Double click on each of this, which will load the class to work with.

Inside of those, you may add your code.

You can create a timer if you wish running at 100ms and if the user clicks the button and holds, then the timer goes and the moment he releases, inside that, you could have timer1.stop();

Upvotes: 3

Related Questions