I have 2 picture boxes, both with a background image. One of them has a foreground image, too. I want to drag the foreground image from one picture box and place it over the background image of the other picture box. When I test it I get a circle with a line through it as I try to drag the image and nothing happens when I release the mouse.
Here is my code (much simplified but nothing relevant missed out :
Can anyone spot what I'm missing here, please?
Here is my code (much simplified but nothing relevant missed out :
Code:
Public Class Form1
Private MouseIsDown As Boolean
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
PictureBox1.BackgroundImage = My.Resources.Image_background
PictureBox1.Image = My.Resources.Image_foreground
PictureBox2.BackgroundImage = My.Resources.Image_background
PictureBox1.AllowDrop = True
PictureBox2.AllowDrop = True
End Sub
Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
If Not PictureBox1.Image Is Nothing Then
MouseIsDown = True
End If
End Sub
Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
If MouseIsDown Then
PictureBox1.DoDragDrop(PictureBox1.Image, DragDropEffects.Move)
End If
MouseIsDown = False
End Sub
Private Sub PictureBox2_DragDrop(sender As Object, e As DragEventArgs) Handles PictureBox2.DragDrop
PictureBox2.Image = PictureBox1.Image
End Sub
End Class