Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a playlist editor for my app that displays video files in a ListView and show the thumbnails for the files added. I'm using Drag and Drop to add the files to the ListView. I can add the files (the file name and details are displayed ), but no image. Here's the code that I am using:

VB
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As  _
    System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            Dim i As Integer

            ' Assign the files to an array.
            MyFiles = e.Data.GetData(DataFormats.FileDrop)
            ' Loop through the array and add the files to the list.
            For i = 0 To MyFiles.Length - 1
                ListBox1.Items.Add(MyFiles(i))
            Next
        End If
    End Sub


    Private Sub ListView1_DragEnter(ByVal sender As Object, ByVal e As  _
System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub

    Private Sub ListView1_DragDrop(ByVal sender As Object, ByVal e As  _
    System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            Dim i As Integer

            ' Assign the files to an array.
            MyFiles = e.Data.GetData(DataFormats.FileDrop)
            ' Loop through the array and add the files to the list.
            For i = 0 To MyFiles.Length - 1
                ImageList1 = e.Data.GetData(DataFormats.Bitmap)
                ListView1.LargeImageList = ImageList1
                ListView1.Items.Add(MyFiles(i))
            Next
        End If
    End Sub


Please help!
Posted
Comments
Sandeep Mewara 16-May-12 1:36am    
And the issue is?
7774tlas 16-May-12 7:02am    
It doesn't display the thumbnail of the .wmv file in the ListView, only the file name, etc. I need it to show the thumbnail/image of the file as it does in explorer, can you help?

1 solution

OK, I don't see any code that goes to the file and gets or generates any thumbnail image.

What? You thought the ListView was going to do this for you? Uhh, no. You have to write that bit of code yourself.
 
Share this answer
 
Comments
7774tlas 16-May-12 15:50pm    
Sorry, I'm a novice and I'm still learning. I thought that the ListView would display the thumbnail image of a file if I added it to the ImageList, but apparently this is not the way to do that. (and you don't have to be condescending, I wouldn't be here asking questions if I were an expert)
Dave Kreskowiak 16-May-12 18:06pm    
All you have to do is read the documentation on the controls you're using.

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