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).
You can rightclick the picturebox -> Properties-> and there should be an image field with the informations you search
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.
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.
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.
Related
I have some custom popup menus in my app and i am tired of using the .FaceID property just to set some "not so relevant" images form my commands. What i want to do is to get some pictures saved in a local table OLE-OBJECT field and display those instead of the MS pictures.
The controls of commandbar object have .Picture and .Mask properties which work just fine if i load a file from the hdd into a IPictureDisp object using stdole.LoadPicture, but i don't want to have hundres of small files in my app folder.
So, my question is: is there a way i can get the picture saved in the local table to become a IPictDisp. I can get it's byte array just fine, but i found no way of converting that into something that the Commandbar button can recognize.
Thank you for any help.
I am coding a game of Noughts and Crosses in a Windows Form Application using VB.NET. I want to display the symbols ("X" and "O") by adding a user control to the solution and changing its backgroundimage property to the appropriate symbol each time someone plays based off a boolean variable which is used to determine whose turn it is. The symbols are stored as .png files in the resources folder of the solution.
What is the syntax for changing the backgroundimage property?
I've got as far as:
'''Symbol1.BackgroundImage = '''
after that I do not know how to set it to a specific image located in the resources folder.
Any help appreciated.
Please ask if not clear enough.
We have been using PDF file as a part of help docs in our vb.net desktop application. In PDF, we would traverse to the certain chapter in the PDF doc.
Now we have decided to use MadCap Flare as documentation tool. We have a menu item in vb.net form for documentation. On click of the link, we want to open the specific chapter of the Flare documentation.
You know managing content with single-source XML authoring is possible when using MapCad Flare (I'm not using Flare!). You can publish content to an increasing number of formats including HTML5, WebHelp, PDF, Word, XHTML, Clean XHTML, EPUB, DITA and more by MapCad Flare.
So, you may continue using PDF and the way connecting your vb.net desktop application help.
Using HTML based topics maybe another solution for your needs by creating Help for a form, a dialog or control with HTML files (See also: Help for controls with VB .NET).
Properties to display help (HTML file - local)
Activate the hlpProvider component hlpHtmlLocal and set the HelpNameSpace property of hlpHtmlLocal to the file name you want to work with.
We open a local HTML file with the dialog using the little button to the right.
The next step is to set the HelpNavigator property of a control (e.g. button) to a value of the HelpNavigator enumeration (see table below). Here we use Topic.
When the application is running click the HelpButton to enable "What's this .." Help. The cursor changes. Now click the button or press F1 when the button has focus. This will open the single HTML file in your browser.
It seems you can't use anchor names to jump to a specific part of your HTML file.
Properties to display help (HTML file - Server http://..)
Activate the hlpProvider component and set the HelpNameSpace property of hlpHtmlServer to the file name you want to work with. Here we use a http:// address of a single HTML file. If you provide the file on your company server, you don't have to update the help file with the customer.
The next step is to set the HelpNavigator property of a control (e.g. button) to a value of the HelpNavigator enumaration (see table below). Here we use Topic. Then we set the HelpKeyword on hlpHtmlSever property to e.g. "anchor3". Don't add a leading "#". Leave it empty if you want to open a HTML file without anchors. The Help Handles cmdControl2.Click Dim sHelpFile As String Dim sStartupPath As String '--- Initialize context-sensitive help --- Keyword property provides the key information to retrieve the help associated with the control.
When the application is running click the HelpButton to enable "What's this .." Help. The cursor changes. Now click the button or press F1 when the button has focus. This will open the single HTML file over the Internet in your browser.
I have some old vb.net forms (can't find out which version they were using when they made them), and I can't find the form's Width and Height in any of the files.
The forms don't have a .designer.vb file, and it's not in the .vb "Windows Form Designer generated code" section either. However, when I open the form in the design view, I can see the values perfectly in the Properties tab.
I've tried making a file search for the values independently but there are nowhere to be found.
Any suggestions or ideas?
I have googled for some time but I can't find anything that helps.
After some tests, I'm quite sure the value comes from the sizes of everything else it has inside.
The form has various Group controls that "force" the Form's size, and therefore, there's no need to stablish it manually. If I do so, the values appear as usual, but otherwise, they are not stored anywhere.
I am using "ImageLocation" property of PictuerBox to get a picture from the web.
PB1.ImageLocation = "http://www.example.com/picture.png"
Some times the image which has to load in picture box from web is very large in size and can not be appear instantly in PictureBox. I need to conform that Image has successfully loaded in Picturebox, before performing next operation.
I have to Enable some controls just after loading of image from web.
Is there any way to conform this?
(Note: My PictureBox has an initial image also.)
Use the PictureBox.LoadCompleted event.
Okay see what I did for mine was just download the picture. The image normally takes a while to start getting put into the picture box.
Here is my code:
If (My.Computer.FileExists("http://www.example.com/picture.png")) Then
My.Computer.Network.DownloadFile("http://www.example.com/picture.png", <Some Location>)
PB1.ImageLocation = <Some location>
Else
End
End If
It may not be the most efficient way - but I can see it as a simple way of making it work.
Dunno if it's working or not, can't access Visual Studio at the moment