Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i will love to create custom events on vb.net add it to elementhost drag and drop file in the elementhost it will add the file to my listviwe thank for your help


VB
Public Sub ElementHost1_Dragdrop(sender As Object, e As Forms.DragEventArgs) Handles ElementHost1.DragDrop
       If e.Data.GetDataPresent(DataFormats.FileDrop) Then
           Dim filePaths As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
           For Each filePath As String In filePaths
               Dim MyDuration As String = GetDuration(filePath)
               Dim chkExt As String = _
           My.Computer.FileSystem.GetFileInfo(filePath).Extension
               'I'M STILL LEARNING SO PLEASE DON'T CRITISIZE ME TO BAD....
               'THIS IS THE ONLY METHOD THAT I KNOW HOW TO CALCULATE THE FILE SIZE....
               Dim chkSize As String = _
           My.Computer.FileSystem.GetFileInfo(filePath).Length
               chkSize = chkSize / 1024

               'THIS IS WHAT I USED TO ROUND THE SIZE TO 2 DECIMAL POINTS...
               Dim d As Decimal
               d = Decimal.Round(chkSize, 2, MidpointRounding.AwayFromZero)

               'THIS WILL ADD THE FILEPATHS AND THE FILES SIZE TO THE LIST VIEW

               'LI = myplaylist.Items.Add(filePath)
               'LI.StateImageIndex = 0
               'LI.SubItems.Add(d & " kb")
               objItem = myplaylist.Items.Add(filePath)

               objItem.SubItems.Add(My.Computer.FileSystem.GetFileInfo(filePath).Name)
               objItem.SubItems.Add(MyDuration)
               Dim objMP3V1 As New MP3ID3v1(filePath)
               If (objMP3V1.TagExists) Then
                   objItem.SubItems.Add(objMP3V1.Frame(MP3ID3v1.FrameTypes.Album))

                   ' MessageBox.Show(objMP3V1.Frame(MP3ID3v1.FrameTypes.Album))
                   ' MessageBox.Show(objMP3V1.Frame(MP3ID3v1.FrameTypes.Artist))
               End If

           Next filePath
       End If
Posted
Updated 11-Jan-15 22:32pm
v2
Comments
Thava Rajan 12-Jan-15 1:56am    
can you show your code so far you have done and where you stuck?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900