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:
Private Sub PictureBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox.DragEnter If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then ' Allow drop. e.Effect = DragDropEffects.Copy Else ' Do not allow drop. e.Effect = DragDropEffects.None End If End Sub Private Sub PictureBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox.DragDrop On Error GoTo Handler Dim Pic() As String = e.Data.GetData("FileDrop", False) 'Get path and filename of Picture PictureBox.Image = Image.FromFile(Pic(0)) Handler: MsgBox("Error loading picture", vbCritical, "PictureBox Error") Exit Sub End Sub


Reply With Quote