Dragging around the form

Christopherx

Well-known member
Joined
Jul 4, 2010
Messages
58
Programming Experience
Beginner
hey guys! Been a while since i've bothered you gentlemen with my questions, but im back! So, I want to know, how I would be able to drag a picturebox around a form, liek a drag and drop functionality, but I dont want to move folders. Just move it around the form. Any suggestions?
 
Handle the MouseDown and MouseUp events and set and reset a flag to indicate that your in dragging mode. Handle the MouseMove event and, if you're in dragging mode, move the PictureBox the same amount as the cursor has moved. That also means you'll need to record the cursor's previous position, i.e. set a field on the MouseDown and MouseMove events.
 
Okay, so i'd like to complicate it a little further! Dragging and moving dynamically created picture boxes. I figured out that they'd just need the functions added to them via the addhandler method, but I dont know how the program can work out which picturebox was actually clicked on, if you get me.
 
Back
Top