DragOver Event Example

This example demonstrates one way to indicate a valid drop target. The pointer changes from the default arrow to a special icon when a TextBox control is dragged over a PictureBox control. The pointer returns to the default when the source is dragged elsewhere. To try this example, paste the code into the Declarations section of a form that contains a small TextBox and a PictureBox. Set the TextBox control's DragMode property to 1, and then press F5 and drag the TextBox over the PictureBox.

Private Sub Picture1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
   Select Case State
      Case vbEnter
   ' Load icon.
         Source.DragIcon = LoadPicture("ICONS\ARROWS\POINT03.ICO")
      Case vbLeave
         Source.DragIcon = LoadPicture()   ' Unload icon.
   End Select
End Sub

Private Sub Picture1_DragDrop (Source As Control, X As Single, Y As Single)
   Source.DragIcon = LoadPicture()   ' Unload icon.
End Sub