Jarron
Jarron

Reputation: 1049

Detect MouseUp after Leaving MouseDown Control

Using VB.NET, Short of adding a mouseup event to every control in my form, does anybody know a way to trigger a mouseup event regardless of where the cursor is located or what control the cursor is in?

Or is there a way to see if the mouse left button is up, that way I can do on enter, if mouseup then...

Upvotes: 1

Views: 1149

Answers (1)

Anthony
Anthony

Reputation: 9571

Or is there a way to see if the mouse left button is up, that way I can do on enter, if mouseup then...

There is a static property on the Control class - Control.MouseButtons which returns, in the form of a flag based enum, which buttons on the mouse are currently pressed.

var pressedButtons = Control.MouseButtons;
if (!pressedButtons.HasFlag(MouseButtons.Left))
{
    // Left mouse button is not down, so do stuff
}

Upvotes: 3

Related Questions