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 void cboPictures_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Display the picture selected in the combo box.
            string filename = cboPictures.Text;
            Text = filename;
            picShow.Load(filename);
        }

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 autosize 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