Apply changes to mainforms Form.Icon at runtime

后端 未结 4 996
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 01:57

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:



        
4条回答
  •  不思量自难忘°
    2020-12-07 02:05

    I Guess, first of all, your GetObject(...) is returning null. Thats the reason the type casting is ending up silently neither throwing error nor change the icon.

    Instead,if possible, use

    this.Icon = new System.Drawing.Icon(...) 
    

    overloads and then give a try.

提交回复
热议问题