Moving an image in C#
I'm using Visual C# and im trying to move a picture box around the field using Mousedown and Mousemove but they are not working...>.>
Anyone have an idea of what the code may look like? I think somethings really wrong with mine.
BenPosted Sep 3, 2009, 5:27 PM
You need to declare a boolean to use as a flag, and a point to register the position of the mouse when you press the button compared to the topLeft of the image. In the MOUSEDOWN EVENT you save the position of the mouse, in the MOUSEMOVE EVENT if the left button is pressed, you move the picturbox. In the MOUSEUP EVENT you set your flag back to false.
Hope it helps with your problem.
shena forgaPosted Sep 4, 2009, 1:16 PM
Roei BarPosted Sep 3, 2009, 5:13 PM
are you trying todo a drag and drop
if so here is a nice post on howto do that
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/DraganddropthePictureBox.htm
hope this helps