I
Ikey
I am trying to allow a user to drag a Picturebox control around the
form and drop it in a new location.
Currently, I was trying to use the following:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button() = Windows.Forms.MouseButtons.Left Then
sender.Location = e.Location
Debug.Print(sender.name.ToString &
sender.location.ToString)
sender.Refresh()
Me.Refresh()
End If
End Sub
Originally, I didn't have the Refresh calls in there but added them
because the object appears to flicker between 2 locations. I then
added the Debug.Print to see the following:
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
If I press the left button down and move the PictureBox even a little
bit and hold the mouse still, the box flashes between the 2 locations.
Is there something I missing or a better way to accomplish this?
Thanks,
Michael
form and drop it in a new location.
Currently, I was trying to use the following:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button() = Windows.Forms.MouseButtons.Left Then
sender.Location = e.Location
Debug.Print(sender.name.ToString &
sender.location.ToString)
sender.Refresh()
Me.Refresh()
End If
End Sub
Originally, I didn't have the Refresh calls in there but added them
because the object appears to flicker between 2 locations. I then
added the Debug.Print to see the following:
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
PictureBox1{X=65,Y=46}
PictureBox1{X=77,Y=28}
If I press the left button down and move the PictureBox even a little
bit and hold the mouse still, the box flashes between the 2 locations.
Is there something I missing or a better way to accomplish this?
Thanks,
Michael