PDA

Click to See Complete Forum and Search --> : Icon


simon ong
Aug 25th, 2007, 12:13 PM
Can anyone tell me what is wrong with this code ?

m_notifyicon.Icon = new Icon(this.GetType() ,"Icon1.ico");

I have this error' Icon1.ico not found in class "Win..."

Resource

Thanks

RobDog888
Aug 25th, 2007, 01:23 PM
Did you set the icons property to Embedded resource instead of Content?

simon ong
Aug 26th, 2007, 12:07 AM
Did you set the icons property to Embedded resource instead of Content?


Yes, I did . But If I change the code to this

m_notifyicon.Icon = new System.Drawing.Icon(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WindowsApplication6\WindowsApplication6\Icon1.ico");

It work. But I would like to understand why?


Thanks:confused:

Paul M
Aug 26th, 2007, 11:32 PM
You didn't import the correct classes.

At the top of the class file you should have added
using System.Drawing;

penagate
Aug 27th, 2007, 07:52 AM
If you pass this.GetType() as the first parameter you're specifying that the icon is an embedded resource belonging to the current class. In your second sample you're not doing that.