How to change Icons?

vnarod

Regular
Joined
Mar 22, 2002
Messages
84
I need to change Form Icon during run-time. Where can I store icons? I don't want to keep them as separate files and ImageList stores them in Picture format that is incompatible with Icon format.
 
Add them to your project, and mark their Build Action as "Embedded Resource". Then you can get them with Assembly.GetManifestResourceStream() at runtime.
 
I am not sure how to use it. There is no samples in help. I tried
fm.Icon = System.Reflection.Assembly.GetManifestResourceStream("explorer.ico")

but it gives an error. Can you show me an example,please?
 
Visual Basic:
fm.Icon = New Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyNameSpace.explorer.ico"))

Check your root namespace by going in to project properties, and that should work ok.
 
Sorry - I should've been clearer. How do I mark the Build Action as "Embedded Resource"?



Edit: DOH!!! I was definitely being a bit thick. Found it in the property window.
 
Last edited:
Back
Top