the edits below should create a vertical list of images. if you want columns and rows, it will take a bit more math work. I think the easiest way to go would be the listview. Using the edited code below will at least help us determine if the imageControl's images are different.
Public Class Form1
Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click
Dim OpenFileDialog1 As New OpenFileDialog
Dim curTop As Integer = 0
OpenFileDialog1.Filter = "Images (*.BMP;*.JPG;*.GIF,*.PNG,*.TIFF)|*.BMP;*.JPG;*.GIF;*.PNG;*.TIFF|" + "All files (*.*)|*.*"
OpenFileDialog1.Multiselect = True
OpenFileDialog1.Title = "Select Photos"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
For Each file As String In OpenFileDialog1.FileNames
Dim imgFilename As String = IO.Path.GetFileNameWithoutExtension(file)
Dim img As New System.Drawing.Bitmap(file)
Dim imgImage As Image = Image.FromFile(file)
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
imageControl.Top = curTop
curTop += imageControl.Height
PhotoGallery.Controls.Add(imageControl)
Next
End If
End Sub
Public Function ThumbnailCallback() As Boolean
Return False
End Function
End Class
Also on a note, Change PhotoGallery from a Picturebox to a Panel Control So that you can scroll through your thumbnails. Just Set the AutoScroll Property to true.
Alternatively Below will display the Thumbnails in multiple Columns and Rows.
Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click
Dim OpenFileDialog1 As New OpenFileDialog
Dim cols As Integer = (PhotoGallery.Width - (PhotoGallery.Width Mod 100)) / 100
Dim curLeft As Integer = 0
Dim curTop As Integer = 0
OpenFileDialog1.Filter = "Images (*.BMP;*.JPG;*.GIF,*.PNG,*.TIFF)|*.BMP;*.JPG;*.GIF;*.PNG;*.TIFF|" + "All files (*.*)|*.*"
OpenFileDialog1.Multiselect = True
OpenFileDialog1.Title = "Select Photos"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
For Each file As String In OpenFileDialog1.FileNames
Debug.Print(file)
Dim imgFilename As String = IO.Path.GetFileNameWithoutExtension(file)
Dim img As New System.Drawing.Bitmap(file)
Dim imgImage As Image = Image.FromFile(file)
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)
If myThumbnail IsNot Nothing Then
imageControl.Image = myThumbnail
Else
imageControl.BackgroundImage = myBitmap
imageControl.BackgroundImageLayout = ImageLayout.Zoom
End If
imageControl.BackColor = Color.Black
imageControl.Left = curLeft * 100
imageControl.Top = curTop * 100
curLeft += 1
If curLeft >= cols Then
curLeft = 0
curTop += 1
End If
PhotoGallery.Controls.Add(imageControl)
Next
End If
End Sub
Public Function ThumbnailCallback() As Boolean
Return False
End Function