Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying image objects 1

Status
Not open for further replies.

DimMeAsNewbie

Technical User
Mar 17, 2007
20
GB

Help!
I've saved my images in the Debug folder withing my VB.NET project.
How do images appear in my picture box;

I've got this at the moment:

PictureBox1.Image = Image.FromFile("image0001.gif")

This is giving me a file path error, but the image is really does exist and the name is correct.
 
FileNotFoundException error,
Is there any other way of storing and displaying images?
I know how to add to imagelist but how do i make the images in the imagelist display in the picbox at run time?
 
Hi

Writing the name only, the application will search for it where the exe is. Make sure that the exe and the gif are in the same folder. Perhaps you has changed the path that visual studio builds the exe (?) so when you press the start with or w/ debugging button, the app do not find right besides the image.

Yes there are some other ways.
1. The image list is for storing small images (best) that can be used for toolbars for example.
2. Also you can change the build option of the image (solution explorer) to embedded resource, read the stream into memory and write it in the picrue box.
3. You can also add to your project assembly resource files where you can store sounds, strings, images etc.

Go to these solutions if it is your last option
 
To load from imagelist:

Me.PictureBox1.Image = Me.ImageList1.Images(..)

Where ".." can be the index (integer) of the image in the collection, or can be the name (string) of the image, e.g. "pic1.gif". This is called the KEY.

The image list will reduce the images' size. Do not use it unless the images are same size and small (for better), e.g. 16x16
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top