Visual Basic Reference

DragDrop Event Example

This example demonstrates the visual effect of dropping a PictureBox control onto another PictureBox control. To try this example, paste the code into the Declarations section of a form that contains three PictureBox controls. Set the DragMode property for Picture1 and Picture2 to 1 (Automatic). Use the Picture property to assign bitmaps to Picture1 and Picture2, and then press F5 and drag Picture1 or Picture2 over Picture3.

  Private Sub Picture3_DragDrop (Source As Control, X as Single, Y As Single)
   If TypeOf Source Is PictureBox Then
      ' Set Picture3 bitmap to same as source control.
      Picture3.Picture = Source.Picture
   End If
End Sub