I am trying to change the icon of the form (top left) and any other place I see little squares default icon.
I have tried:
Clicking the form, go to "Window Style" and changing the Icon to the .ico file I have on my computer - this shows as if it actually changes - but whenever I debug or publish - it is still the original default Icon.
Going to Project's properties- Resources - adding the Icon as Resource - back to Application under Properties - change "Icon and Manifest" to the resourced Icon. It shows the new Icon next to the browse button - but nothing changes in the actual program.
Note at first the Background Image I had selected for the form wasn't applying either - I would change it via the form - Properties - Appearance - BackgroundImage - Select from computer. Would show as changed but as soon as I would debug or publish or would not be there.
-Added it to my resources and then chose it from the BackgroundImage browse - chose it from project resources and then it worked.
Found a solution:
With the idea that my Background image wasn't working until I had it in the Resources. I went to the Form1_load event and added the following code:
System.Drawing.Icon ico = Properties.Resources.Untitled;
this.Icon = ico;
As "Properties.Resources.Untitled" being my icon that I added to my Resources.
And now seems to be workings as wanted.
You need to change the icon on every form as well using the Icon property of the Form.
Related
I want to use two different icons for my Visual Studio program, one for the left side on the window and another for the taskbar. Is there any way to do it? Thank you.
edit: I mean I want to have two different icons, one for the window and another for the taskbar, as you can see in the imagesm because when you upload an icon it automatically puts the same icon for both of the situations mentioned in the images.
# Samuel.
The .ico file can contain multiple images. When you load the .ico file, Windows selects the most suitable image according to the current display mode and system settings to load one of the images.
You could create a multi-size icon with the different image and set the size to 64x64, 32x32, 16x16 respectively. In this way, you can include different images in one icon. Then set the Icon property of the form: select the prepared icon and click open.
When you run, you will get the effect in the picture below.
I am totally stumped by this issue and I do not know what to do.
I have created a simple C# Windows Form application using Visual Studio 2012 Premium. I have a small program that starts up and creates a NotifyIcon in the system tray. On click of the tray icon, a context menu is displayed and it shows a few menu options (Options, About, etc.), where each option displays a form. I have added two icon files (.ico) via the Resources by right clicking on my Project item, Properties, Resources. I programmatically change the Icon of my NotifyIcon, alternating between the two different icons. My problem is that my old icons keep displaying, instead of my new ones that I've added to the project. To be clear, my issue is that OLD icons keep displaying--everything is working and there are no errors, it just doesn't show my latest icons.
The way I'm changing the icons in code is using:
notifyIcon.Icon = Resources.IconA03312014; //or the other one; the numbers are the date
I initially made my icons and used those and later decided to change them a little bit--I changed some colors, etc. So then I removed the old icons from my project by clicking the Exclude from Project option. Then I added my new icons, which had different names. Then I updated my two code references that load the icons to use the new names. No matter what I do, my new/updated icons are not displayed!
Whether I run the program in Visual Studio in Debug or Release mode, it does not matter. I can clean the solution, rebuild, and then run the executable directly by clicking on it in Windows, and no difference. Old icons are shown.
I have followed different sets of instructions online that explain how to clear the Windows 8 icon cache (three different methods). I have cleared the cached Notification tray icons as well, using two different methods.
Basically, I cleaned my solution and then closed Visual Studio. I kill all explorer processes, run ie4uinit.exe -ClearIconCache from the command line and delete the IconCache.db file. Then I delete the notification icon cache by editing the registry following instructions similar to these (http://www.sevenforums.com/tutorials/13102-notification-area-icons-reset.html). Then I shutdown the computer. Upon starting backup and rebuilding my solution and running, the old icons are still there somehow. The physical .ico files for the old icons were deleted long ago. Each time I've added new icons to my Resources, I've created new icon files from scratch (using icobundl.exe) and named them uniquely by including the date in the name. I am aware that Windows, and apparently Visual Studio also, like to cache icons and if you delete some icon file A.ico in Windows and then rename another icon file B.ico to A.ico, the B.ico file's actual icon will change to A's. Anyway, I don't the name of the icon file is the issue.
Now, in code, if I use the same strategy and set one of my form's icons, it works correctly and the form displays my latest icon, while my notify icon still shows the old (and now nonexistent, except in Visual Studio la la land) icon.
So, I have:
...
if(firstState){
notifyIcon.Icon = Resources.IconA03312014;
optionsForm.Icon = Resources.IconA03312014;
}
else{
notifyIcon.Icon = Resources.IconB03312014;
optionsForm.Icon = Resources.IconB03312014;
}
firstState = !firstState;
...
There are no errors and both the notifyIcon and optionsForm's changes, but the notify icon displays my OLD icon that no longer exists anywhere (except somewhere/somehow in VS). The form's icon changes to my updated/latest icon.
If I copy my app's .exe file to another computer and run it, it too displays the old icons for the notify icon, so the old icons are somehow still embedded in my exe generated by Visual Studio. If I just directly load the .ico file, instead of referencing my project resources, the new icons ARE shown. This have to be some sort of strange Resources caching issue in Visual Studio?
Can anyone please help me with this issue? I just don't understand how my old icons are still existing somewhere, and how Visual Studio somehow knows how to switch them! That's right, the above icon swapout works perfectly for the form. But for the notifyIcon, the icon does switch from "A" to "B", but it uses the old A icon and the old B icon--icons that do not exist anywhere anymore!
I hope I have explained my issue. I greatly appreciate any help that anyone can provide.
I had this same problem a few months ago and it drove me crazy for a couple of hours. I was so focused on clearing on the icon cache and thinking that it was just some sort of caching issue that it didn't immediately occur to me what the real problem was.
The answer, for me at least: Even though you have a 16x16 version of your image in your .ico file, Visual Studio will instead use the 32x32 image and scale it down to 16x16, causing it to look distorted. I say VS did it because when I ran the executable on other machines (different Windows OS's), I saw the same behavior so it wasn't a Windows 8 issue, for me. (It might very well be a Windows issue in general though, I don't know. I did not take the time to verify what was actually inside of the generated .exe--did it contain MY 16x16 version, or 16x16 version generated by scaling down my 32px version? That would have confirmed it, I guess...)
My "aha" moment came when I added a few rows of red pixels to each size of my icon image, in a different section of my icon. So I put the red rows in my 16x16 at the bottom. My 32x32 had the red rows in the center, etc. So then I added this .ico to my project and started the project up and BAM, there was a distorted version of my 32x32 icon being used in the system tray as my notify icon. There was no doubt about it.
If you notice that your notify icon (at 16x16) looks more distorted than you would expect, you might use a similar strategy to see if this same automatic scaling is happening. When I figured this out, my quick solution was to add a .ico to my project that contained ONLY the 16x16 version of my icon image. I then use that resource image only for my notify icon. Obviously, if you did this (have a 16x16 only image) for forms, for example, you would see a very distorted icon in your taskbar, Alt-Tab list, etc., because Windows has no choice in that situation but to create the different icon image sizes by scaling your 16x16 because that's all that you supplied. Anyway, in my particular case, as I believe is yours as well, there was no issue using the .ico for forms--they show the actual embedded 16x16 version of the image and there is no "automatic downsizing" of the 32px version.
That's all I know. I did not spend anymore time on this issue because I had to move on. I hope this helps someone avoid some icon frustration. Why, oh why, VS would you do this to us!?
i had the same problem with a splash screen.
some how it did not change after replacing the picture.
what i did is i remove the images then save the form.
run the app and there was no image.
then i replaced them and the problem was fixed for me.
so maybe you can try the same with you're icons.
hope it will fix you're problem .
Open the file Resources.resx of your project with the editor. There you have to change name="Icon1" into name="YourIconName".
I have assigned an icon to my application from the Properties window in Solution Explorer in Visual Studio; the application's icon changed successfully but the title bar is still showing the default icon:
I've rebuilt my application but it still displays the default icon. What am I doing wrong?
Because forms have a different icaon configuration than the application. Set the icon on the form, not ONLY on the application.
There is another reason why the icon might not show.
If the ControlBox property of the Form is set to False the icon will not show.
(Sounds like an undesired side effect)
I know that it is a very old issue but I can add the following comment :
Pay attention to the 'FormBorderStyle' property.
If 'FixedToolWindow' or 'SizableToolWindow' are selected, your icon will not appear, even if you specified an icon in the 'Icon' property.
I encountered the same issue.
Good luck.
The form itself has an Icon property you need to set as well.
If you using winform you need to set the icon property of your main form
You didn't mention if you are using winforms or wpf - wpf will place the icon on all windows/forms unless overridden.
Winforms requires individually set icons.
With the Weifen Luo DockPanel component, one can add to their .net project the ability to dock forms within other forms. The component is very well done.
Now, I see from this page at the project forum at github (where this component is now hosted), that it is possible, through the use of this dock.extender to allow the floating windows to have a normal winform look, that is, sizeable with regular Windows title bar, maximize box, minimize box, etc (see here, too). This also allows for the form's icon to show.
My problem is, and hence my question, is that the icon I assign in the form's properties will show in the designer, but one it runs in debug as a float-panel, a generic form icons appears in its place.
Now, I tried assigning the icon through code (both in the form's own code, and in the main application code too, where the form is called) rather than through properties, and that didn't work either.
So how do I get my own custom icon to show as the form's icon when the form is floated, and the extender is used? I am using the main docking panel in DockingWindow mode.
[EDIT]
I think this is a hard question! It's been 2 days and I've not gotten any answers!
This requires a change to the the FloatWindow class itself to set and update the Icon property internally as the content changes.
I have just checked the change in and it will be included in the 2.7 release of the library.
https://github.com/dockpanelsuite/dockpanelsuite/issues/35
Usually I have to set 2 different icons. One in the project's settings tab, and one to the Icon property of main window. Is there a way to define single icon for the whole application (all windows and exe)?
Update: to be more concrete. I have app that is 100kb in size. I want to embed icon that is 300kb in size and want my app to be 400kb instead of 700
You need to set the icon in you project's properties:
For taskbar you need to change your main window's Icon:
When you set your exe icon, WPF will use that for all Windows you create. However, it doesn't do it in debug mode - that's because the "entry point" for your process is the .vshost.exe, not your exe. But if you use Ctrl+F5 (run without debugging), you should find all Windows get the exe icon. You shouldn't have to set it on each Window.
To make it work properly in debug mode, I generally set up a Style which I apply to each window, which sets the application icon.