I have a picture box that I want to drop a file onto. Im testing it with pictures just to get things going. But it wont work. It wont allow any files to be droped onto it. I set allow drop to True on the form also.

Here's what I have so far:

VB Code:
  1. Private Sub PictureBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox.DragEnter
  2.         If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
  3.             ' Allow drop.
  4.             e.Effect = DragDropEffects.Copy
  5.         Else
  6.             ' Do not allow drop.
  7.             e.Effect = DragDropEffects.None
  8.         End If
  9.  
  10.     End Sub
  11.  
  12.     Private Sub PictureBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox.DragDrop
  13.         On Error GoTo Handler
  14.         Dim Pic() As String = e.Data.GetData("FileDrop", False) 'Get path and filename of Picture
  15.         PictureBox.Image = Image.FromFile(Pic(0))
  16. Handler:
  17.         MsgBox("Error loading picture", vbCritical, "PictureBox Error")
  18.         Exit Sub
  19.  
  20.     End Sub