I have a System.Windows.Forms.Form and want to change the Form.Icon at runtime to display a status. I’ve managed to load the icon from the projects ressources:
Type type = this.GetType();
System.Resources.ResourceManager resources =
new System.Resources.ResourceManager(type.Namespace + ".Properties.Resources", this.GetType().Assembly);
this.Icon = (System.Drawing.Icon)resources.GetObject(
type.Namespace + ".Icons." + statusText + ".ico");
But the displayed icon stays the same (design time icon) all the time. Do I have to call a method to tell the Form to apply changes? Something wrong about my usage of Form.Icon?
Ok, Siva and Hans where right: GetObject returned null, because the name of the ressource wasn’t right. With the following change it works:
Thanks for all your help.