Restricting mouse movement on dragged mouse events

Hi

Once I click and start dragging my mouse, I would like to bound (restrict) its movements to the component it initially started from...is this possible

Can't find anything on it...

Thanks

Ashwin



Answer this question

Restricting mouse movement on dragged mouse events

  • Des Jacobsen

    Directly no... however with a little math you can determine the position and size of your control on the form and the monitor and create a rectangle area from it and use that to set the Clip property of the static Cursor class (found in System.Windows.Forms).

    I’d suggest looking into both the Size, Location and DisplayRectangle properties of the form that your controls are hosted on in order to determine the controls position on the screen.



  • Nick Perez

    Or look into clipping the bounds of the mouse movement!
  • Restricting mouse movement on dragged mouse events