I have taken input of 5 images from user and showed it in photogallery now I want these images in list view too. How should I pass them in list view simultaneously. I tried the below code but it shows images in photogallery not in listview.

Private Sub BrowseMultipleFilesButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles BrowseMultipleFilesButton.Click
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.Filter =
 "Images (*.BMP;*.JPG;*.GIF,*.PNG,*.TIFF)|*.BMP;*.JPG;*.GIF;*.PNG;*.TIFF|" +
 "All files (*.*)|*.*"

OpenFileDialog1.Multiselect = True
Dim index As New Integer

OpenFileDialog1.Title = "Select Photos"

If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
    If OpenFileDialog1.FileNames.Length > 5 Then
        MessageBox.Show("Please select no more than 5 files")
        Exit Sub
    End If
    If OpenFileDialog1.FileNames.Length < 5 Then
        MessageBox.Show("Please select 5 files")
        Exit Sub
    End If
    For Each file As String In OpenFileDialog1.FileNames
        Dim imageControl As New PictureBox()
        imageControl.Height = 100
        imageControl.Width = 100
        Dim myCallback As New Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
        Dim myBitmap As New Bitmap(file)
        Dim myThumbnail As Image = myBitmap.GetThumbnailImage(96, 96, myCallback, IntPtr.Zero)
        imageControl.Image = myThumbnail

        PhotoGallary.Controls.Add(imageControl)

        Dim imageListLarge As New ImageList()
        imageListLarge.Images.Add(myBitmap)
        ListView_images.LargeImageList = imageListLarge
        Me.Controls.Add(ListView_images)


    Next
    btn_Save.Enabled = True
    BrowseMultipleFilesButton.Enabled = False
    End If
End Sub

I wrote a code snippet quite a while back that displays thumbnails in a ListView while preserving the aspect ratio of the original pictures. Just change the values of THUMBW and THUMBH to the desired size. To avoid impacting program response the thumbnails are generated in a background thread. If that's not quite what you are looking for then feel free to post follow-up questions.

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.