How to detect when a Form is being dragged?

c#, drag-and-drop, events, winforms

Solution

Are you talking actual drag-drop operation here, or when the user moves the form? If it is the movement itself, you might be able to use the `ResizeBegin` event, which is raised when the user starts to move the form. This together with `LocationChanged` and `ResizeEnd` should cover your needs. However, the `ResizeBegin` and `ResizeEnd` events are (of course) also raised when you start and end resizing the form, not only when you are moving it.

Problem

I have a Form object with a title bar displayed. I need a pure managed way(P/Invoke-free, both Mono and .NET compatible, preferrably a .NET 2.0 API) to detect when the FORM itself starts being dragged, changes location and when it is dropped(not any content). I did this in the past in Mono but I don't remember how anymore and I don't know if my solution was MS.NET-compatible... If anyone could provide an example, three event names for me to google more details or point me to a relevant StackOverflow question, I would greatly appreciate. So far, my search has returned no relevant results...

Original source