user1464962
user1464962

Reputation: 173

How to check if the mouse moves, while the left mouse button is down, in c#

I need to find a way to check if the mouse moves in c#, while the left button is down.

Upvotes: 14

Views: 9467

Answers (1)

Tim S.
Tim S.

Reputation: 56536

Here's an example (WPF):

public MainWindow()
{
    InitializeComponent();
    this.MouseMove += new MouseEventHandler(MainWindow_MouseMove);
}

void MainWindow_MouseMove(object sender, MouseEventArgs e)
{
    if (e.LeftButton == MouseButtonState.Pressed)
    {
        //do something
    }
}

Upvotes: 23

Related Questions