The PictureBox control lets us display a picture.control lets us select a directory at run time instead of hard coding in a folder such as "c:/mypictures".
Private Sub LstFiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstFiles.SelectedIndexChanged Dim file As String = FolderBrowserDialog1.SelectedPath & "/" & LstFiles.SelectedItem Me.Text = file Me.PictureBox1.Load(file) 'Displays picture in picture box End Sub
When you run the program the browser dialog opens
After selecting a folder, you will see a list of all the files in the folder you selected:
When you select an item in the list box, the picture appears in the picture box.
Experiment: Select a directory with something other than pictures. What happens if you select6 an item that is not a picture?
Using what you know about strings, make sure that only picture formats are added to the list box. What formats can you display?