Greets,
I have two pictureboxes on my form: MapPicture and VictimPic. MapPicture is blank and VictimPic is a bitmap. What I need to do is to be able to drag VictimPic onto MapPicture so that when the user drops it VictimPic will be moved onto MapPicture at the point it was dropped.
The problem I'm having with my current code is that the DragDrop event will either a) move it in relation to the form, on which it is located at startup or, b) VictimPic will disappear. I suspect that in this case it is actually working but that VictimPic is being hidden by MapPicture. If this is so, though, I still don't know how to make it visible on the MapPicture picturebox.
Here is the code right now:
VB Code:
Private Sub VictimPic_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles VictimPic1.MouseDown Dim PB As PictureBox PB = DirectCast(sender, System.Windows.Forms.PictureBox) PB.DoDragDrop(PB, DragDropEffects.Move) End Sub Private Sub MapPicture_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MapPicture.DragDrop Dim PB As PictureBox = e.Data.GetData(MapPicture.GetType()) PB.Location = MapPicture.PointToClient(Control.MousePosition) End Sub Private Sub MapPicture_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MapPicture.DragEnter If e.Data.GetDataPresent(VictimPic1.GetType()) Then e.Effect = DragDropEffects.Move End If End Sub
Thanks in advance for any help. This one is a real doozy!




Reply With Quote