Click here to Skip to main content
14,545,215 members
Rate this:
Please Sign up or sign in to vote.
See more:
In win forms i am creating picture boxes dynamically for each of the image in a specific folder as thumbnails, when the user clicks page down the next picture box should get selected and i need to see the image highlighted please let know how it can be accomplished

What I have tried:

next to thumbnails displayed, i have a control to show the enlarged picture of the selected thumbnail, in the preview it is displaying the correct image but thumbnails are not to the next image
Posted
Updated 23-May-20 1:11am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You could have all your picture boxes in a list, as well as a class-level integer variable holding current picturebox index. On click of the button, just increment or decrement the index, and set focus on corresponding picturebox.
Dim list As New List(Of PictureBox)
Dim currentIndex As Integer = 0

'' Populate the list when you create the pictureboxes

Private Sub NextButton_Click(sender As Object, e As EventArgs) Handles NextButton.Click
   currentIndex = (currentIndex + 1) Mod list.Count
   list(currentIndex).Focus()
End Sub

Private Sub PreviousButton_Click(sender As Object, e As EventArgs) Handles PreviousButton.Click
   currentIndex = (currentIndex - 1) Mod list.Count
   list(currentIndex).Focus()
End Sub
   
v2

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100