הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Wednesday, October 31, 2012 9:05 PM
I'm trying to change the icon on my form at runtime. I thought this would be very simple. I added two icons to the resource tab of the properties of my project.
Then I tried adding the following code:
Me.Icon = My.Resources.xxxx
but the icons that I had added to my resource tab do not show up. All that shows up are bitmap and png images that I've added to the project and they cannot be assigned to the icon of the form.
What am I doing wrong. I've seen some examples where they reference the directory explicitly and I don't want to do this.
Rodney
All replies (7)
Friday, November 2, 2012 3:31 PM ✅Answered
I would suggest
- Backup your project i.e. Source Safe, Subversion, Winzip etc.
- Under project Properties, Resource tab remove all images. (I assume you have these images to add back in)
- Close the project
- From Windows Explorer remove the project's resource folder.
- Load the project.
- Build the project (it should be fine)
- Add one of the Icon images back into the project and retry setting the form icon again. If this works add back in any other icons one at a time and test to see if VS recognizes them.
KSG
Thursday, November 1, 2012 1:52 AM
I added three ICON files to my form
Project tab -> Application properties -> Resources -> Add resource -> Add existing file and browsed for the files and added them to my form. Then I used Me.Icon = My.Resources.xxxx in form load and it works fine for any of the three ICON resources.
You've taught me everything I know but not everything you know.
Thursday, November 1, 2012 8:15 AM
I've the idea you have added the icons as images.
Do you know that there is a special section for icons (A drop down left above the resource pane)
Success
Cor
Thursday, November 1, 2012 10:10 AM
Nope, I added them as icons, I assume this is where you are referring to. If not let me know. I don't know where else to add them.
Thursday, November 1, 2012 1:51 PM
But those don't have the name xxxx, you are sure it is not something like a typo?
Success
Cor
Friday, November 2, 2012 2:48 AM
Hello,
I saw you renamed the resource folder to res. So I suggest check the icon files were add to resource folder. Right click folder and click "open folder in windows explorer". Then "Show all files" in solution explorer, right click Resource.resx select "View code", in the data node check if the file path was valid in windows explorer.
Hope this help.
Think again!
Friday, November 2, 2012 1:19 PM
You were right, the Resource.resx file was pointing to the wrong directory, but even after fixing this it still isn't recognizing my icon files. I've tried a couple thinking it was something about the file itself so my current one is cancel.ico. I'm including two screen shots in case anyone sees something that might help.
So you can see in the above image that cancel.ico is in my resources but in the next image when I try to add it, it doesn't show up...