The Flash movie below shows what the drag and drop project does:
To create this project:Public Class Form1 'Form level variables Dim startPoint As Point 'the point on the picture where we clicked to start dragging Dim dragging As Boolean Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown dragging = True startPoint.X = e.X startPoint.Y = e.Y End Sub 'PictureBox1_MouseDown Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If dragging = True Then 'without the if, the picture will start moving even when the mouse is not down 'instead of putting the picture the same place as the mouse, 'we need to offset it by the point that was clicked to start dragging PictureBox1.Left = PictureBox1.Left + e.X - startPoint.X PictureBox1.Top = PictureBox1.Top + e.Y - startPoint.Y End If End Sub 'PictureBox1_MouseMove Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp dragging = False End Sub 'PictureBox1_MouseUp End ClassLast modified: January 30 2025 14:19:09.