Hi all,

I'm making a program that can search for all .JPG files and display them in a ListBox. Now I want it to display the selected ListBox Item in the PictureBox1.

The files in the listbox are listed like this :

C:\Documents and Settings\My pictures\Image01.JPG


Thanks,

Vhyr.

Here you are

PictureBox1.Image = Image.FromFile(<a filename selected from the listbox>)

There's a DaniWeb's search in the upper right corner. You can try words "vb.net picturebox file" and you'll find the snippet above. With "vb.net listbox file names" you'll find snippets about listbox handling.

HTH

I'm making a program that can search for all .tif files and display them in a ListBox. Now I want it to display the selected ListBox Item in the PictureBox1. Can anyone tell me how to solve this

I did the same thing for a browser app that I wrote. I also wanted to be able to rename the current file but I ran into problems because loading the file directly leaves the file in use. If you load the image using a filestream then the file is released.

Dim fs As New System.IO.FileStream(filename, IO.FileMode.Open, IO.FileAccess.Read)
pbxPicture.Image = System.Drawing.Image.FromStream(fs)
fs.Close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.