Reputation: 9912
I am trying to use Icons in a windows form application. I read that you can use resx files to do this. (I also read that resx files can be used for localization but this is not the point of this question)
I know more or less how to use a resx file if I have one(see below). What I don't know and I can't find anywhere is how to create these resx files (I know what these files are already)
Can someone teach me how to create a resx file that holds information on icons non-programmatically (the few responses about this in SO are programmatical ones)
The objective is to have a "resource.resx" file in my project that holds data about a "myicon.ico" file.
I am planning to use this as in
ResourceManager rm = new ResourceManager("resource",
typeof(Resource).Assembly);
Object ret= rm.GetObject("something");
if(ret!=null && ret is Icon)
return (Icon)ret;
else
return null;
Please don't point me to this link since I have already read it and could not find a practical way to do what I asked.
Upvotes: 7
Views: 18555
Reputation: 38767
Assuming you're using Visual Studio:
Resources
)something
).If you named your resources file "Resources", you should be able to access the icon like so:
Object ret = Resources.ResourceManager.GetObject("something");
if (ret != null && ret is Icon)
return (Icon)ret;
else
return null;
Upvotes: 14