Explorer-Style ListView
Visual Basic
1
Posts
1
Posters
0
Views
1
Watching
-
I have an Explorer-Style ListView and I use
ListView1.View = View.Details ListView1.View = View.LargeIcon ListView1.View = View.List ListView1.View = View.SmallIcon
to update the respective view. I added the ability to view thumbnails with this code:Dim fullPath As String Dim di As New DirectoryInfo(fpath) Dim fi As FileInfo Dim i As Integer fullPath = GetPathFromNode(TreeView1.SelectedNode) ListView1.Items.Clear() '\*\*\* Loop to get the "jpg" files Try For Each fi In di.GetFiles("\*.jpg") ' if path will contain link files, change from jpg to lnk ImageList3.ImageSize = New Size(96, 96) Try CreateThumbNail(fpath & "\\" & fi.Name) ' This returns the thumbnail images With ListView1 ' set the properties for for the ListView ListView1 .Items.Add(fi.Name, i) .LargeImageList = ImageList3 .ForeColor = Color.Blue .Scrollable = True End With Catch Exit Try End Try i += 1 Next ' cycle through fpath until no more \*.jpg.lnk files are found Catch MsgBox("No image files are located in this directory.", MsgBoxStyle.Exclamation, "Thumbnails") Exit Try End Try Private Sub CreateThumbNail(ByVal filepath As String) Dim myImage As New Bitmap(filepath) Dim MyThumbNail As Image '\*\*\* ThumbNail MyThumbNail = myImage.GetThumbnailImage(96, 96, AddressOf Thumbnailabort, Nothing) '\*\*\* Fill the ImageList with Image Collection ImageList3.Images.Add(MyThumbNail) End Sub
The four
ListView1.View = *
work just fine until I execute the routine to view thumbnails. After viewing thumbnails the fourListView1.View = *
routines do not work properly. Among the problems is that only jpg’s are listed in the ListView. Any ideas or suggestions? Thanks Brad