I have a simple winforms application with a number of controls in it. I want to be able to click and drag from anywhere on the form and move the whole set of stuff around (panning). I have figured out the respositioning bit already. What I still need to figure out is how to tie the click and drag into updating my offsets.
What I have tried so far is adding stuff to the main form's MouseDown
, MouseUp
and MouseMove
events (sort of looks something like what this guy shows) , but they aren't getting called (breakpoints in them don't get hit)
What am I doing wrong?
Edit: I'm not looking for drag and drop as I don't necessarily have anything to be dragged or dropped. What I want would work withe the following spec:
- create a form with no controls
- set up an x and y variable that are printed to the form title whenever they update
- when the user click and drags anywhere on the form, the x and y get updated to reflect the motion of the pointer (click and drag down and to the right will result in
x>0
andy>0
)
Based on Eric's comment I think I'm hooking up to the events on the wrong control.
Is there a way to (with a setup like controls use) catch all events in one place regardless of what they are supposed to be sent to? Or how about have any otherwise unhanded events get chained up to the parent? In my case I will never care what got the event so this would be what I want to get.