Hello everyone! i need a bit of help... can you convert my picture drag and drop code so it drag and drops audio files? (.wav) My code:


Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()


InitializeComponent()

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub


Private components As System.ComponentModel.IContainer


Friend WithEvents pb As System.Windows.Forms.PictureBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.pb = New System.Windows.Forms.PictureBox
Me.SuspendLayout()

Me.pb.Dock = System.Windows.Forms.DockStyle.Fill
Me.pb.Location = New System.Drawing.Point(0, 0)
Me.pb.Name = "pb"
Me.pb.Size = New System.Drawing.Size(292, 266)
Me.pb.TabIndex = 0
Me.pb.TabStop = False


Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.pb)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
pb.AllowDrop = True
End Sub

Private Sub pb_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pb.DragDrop
Try
pb.Image = Image.FromFile(CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString)
Catch ex As Exception
MessageBox.Show("Error Doing Drag/Drop")
End Try
End Sub

Private Sub pb_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pb.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
End Class

(this code is for drag and dropping pictures)

Recommended Answers

All 3 Replies

What is wrong with the code from your other thread "Drag and drop"?

after a software update, it stopped working... i still don't know how that happened....
and now that code does not work.....

oh wait never mind i fixed it... looks like i might of accidentaly switcher the .net framework to a different version.......... =(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.