Hi all and happy new year
I need to detect whe the mouse leftclick is being held while moving the mouse upward so how can i do that

Thank you

Edited by shandoosheri: n/a

5 Years
Discussion Span
Last Post by shandoosheri

You need to capture the MouseDown and MouseUp event, set a boolean, and remember the original coordinates:

bool MouseIsDragging = false;
point Start = new point();
private void MyForm_MouseDown(object sender, MouseEventArgs e)
    MouseIsDragging = true;
    Start.X = e.X;
    Start.Y = e.Y;
private void MyForm_MouseUp(object sender, MouseEventArgs e)
    MouseIsDragging = false;
    if (e.Y > Start.Y) //can't remember if Y increases or decreases as you go up...
        MouseHasBeenDraggedUp(); //Condition is met, do something

//If this needs to be monitored in realtime, and not just when the mouse button is up:
private void MyForm_MouseHover(object sender, MouseEventArgs e)
   if (MouseIsDragging == true && e.Y > Start.Y)
      MouseHasBeenDraggedUp();// Condition met

Edited by skatamatic: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.