Reputation: 2341
I'm inexperienced with windows forms (vb.net), and I have a rather silly question.
I'm opening an old project of someone elses, and there's a PictureBox control on the form. The PictureBox has a photo, and I'm trying to find the location of the photo on the computer but can't find it.
In ASPX, I can just look at the code behind and find out where the tags are pointing to (for the photo).
Is there a way to do that for vb.net?
Update: The only code that exists for my object, with the image property is this:
Me.pbTotal.Image = CType(resources.GetObject("pbTotal.Image"), System.Drawing.Image).
Upvotes: 1
Views: 3958
Reputation: 2341
Ok, I just found the true answer. Yes it in a resource file, but not for the project itself. I didn't know that forms themselves have resource files (.resx) as well.
In visual studio 2010 (not sure about the others), the .resx file is hidden. If you click the option to "Show All Files" in the solution explorer tool bar, you'll then see that the form can be drilled down. There in the .resx file, I was able to find my image.
Upvotes: 0
Reputation: 12613
The PictureBox control gives you two options for setting the image that is displayed on it. You can use the ImageLocation
property or the Image
property to perform the same task.
If you set the ImageLocation
to the file name or url of a valid image/picture, image gets displayed and you can access it via the Image
property as well. If you should use the Image
property to set the image displayed, there will be no way to know the physical location of the image being displayed if you did not know it beforehand.
From the code you've pasted in your question, there no way way retrieve the path/url to the image file. To further complicate matters, the image is being loaded from your project's resources so any attempt to resolve the path/url would have to first go through the project resources before locating the original file and even if this is possible, for all practical purposes it is too cumbersome.
In short, if you'd like to get the path/url of the image loaded in the PictureBox at some point later, use the ImageLocation
property instead of the Image
property to set the image to be displayed.
Upvotes: 0
Reputation: 25495
If its not set in the properties window which can be viewed by right clicking on the picture box it will be set in code using the image property.
Upvotes: 1
Reputation: 565
You can rightclick the picturebox -> Properties-> and there should be an image field with the informations you search
Upvotes: 2