A Picture Viewer Application

The third step is to display a picture when the user selects a picture in the combo box.
The user must first select a folder and all of the filenames are displayed in the combo box.
Make sure that that step is working, then add the code to display the picture when the selected index changes.

Continue with the PictureViewer application.

Double click on the cboPictures combo box and write the code shown below:

Private Sub cboPictures_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboPictures.SelectedIndexChanged
        'When an item in the combo box is selected, display in picture box
        Dim pathAndFileName As String = FolderBrowserDialog1.SelectedPath & "\" & cboPictures.Text
        'we need both the folder and the filename to load the picture.
        Me.Text = pathAndFileName
        PictureBox1.Load(pathAndFileName)
End Sub

Test your program and try opening a folder. You should see all the picture files in the combo box and the first one displays.
If the picture shows only one corner, make sure you have set the sizemode to stretch for the picture box.

Save all before moving on to the next step.

Complete code so far

NEXT: Use a timer to create a slide show