Click here to Skip to main content
15,740,731 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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.
VB.NET
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
 
Share this answer
 
v2

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