472,355 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,355 software developers and data experts.

Find an image in a resource file by name

I have a bunch of images named head1, head2, head3... in my
Resources.resx file in my project. How do I get the image if I have
the name as a string?

Jul 27 '07 #1
3 28130
Don't know if this helps, but this is how I get an icon file from my
resource file. I would imaging for an image it will be very similar,
probably only have to cast to a (Bitmap) instead of an (Icon).

Resx File: ProgramResources.resx

C# 2 Code:
*******************************************
using System.Resources;
using System.Reflection;

ResourceManager rm = new ResourceManager(
"YourProgramName.ProgramResources",
Assembly.GetExecutingAssembly());

Program.NotifyIcon.Icon =
(Icon)rm.GetObject("my_icon_name");
*******************************************

ti*****@gmail.com wrote:
I have a bunch of images named head1, head2, head3... in my
Resources.resx file in my project. How do I get the image if I have
the name as a string?
Jul 27 '07 #2
Hi

Look into the archives of this group a post I did a time ago with the code
for doing just that,
google "ignacio machin" resource

<ti*****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>I have a bunch of images named head1, head2, head3... in my
Resources.resx file in my project. How do I get the image if I have
the name as a string?

Jul 27 '07 #3
On Jul 27, 11:33 pm, timn...@gmail.com wrote:
I have a bunch of images named head1, head2, head3... in my
Resources.resx file in my project. How do I get the image if I have
the name as a string?
here is my sample code using in a Winform App:

ResourceManager rm = new ResourceManager("ResourceReader.MyResource",
Assembly.GetExecutingAssembly());
resBox.Image = rm.GetObject("dotnet_logo") as Image;
rm.ReleaseAllResources();

Jul 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andreas Neudecker | last post by:
Hi. I know you can read the filename of a program as sys.argv. But what about modules? Is there a similar way to find out the file name of a module (called by some other module or program) from...
7
by: Jon Davis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;329014 Adding the code at this URL results in an error message: An unhandled exception of type...
1
by: D. Yates | last post by:
Hi, I am looking for an example of how to extract bitmap images from an embedded resource file (a file with *.res extension, which can be viewed inside of the ide and can hold bitmaps, icons,...
0
by: Sanjay Tibrewal | last post by:
Hello, I am trying out a piece of code I downloaded from a link on msdn site. It's a server menu generating control that I tried to add to my custom control assembly. I was able to compile the...
0
by: Tracy | last post by:
I have an question regarding to an visual basic .net resource file. It kept complaining about the line : " Me.grdRevenues.Images.Add(CType(resources.GetObject("resource"), System.Drawing.Image))...
0
by: Agnes | last post by:
I got 6 resource file name label.en-US.resx, label.zh-CN.resx.. etc some file is fail to open and I got the following error "The container cannot be disposed at design time". What's hapend ??...
0
by: gopal | last post by:
Hi, I had an issue with loading/using resource file. I thought i will share this information if it helpful some . I have a console C# application and inside this i have class definition as...
8
by: John Dunn | last post by:
Since currently we aren't allowed to have compiled XAML files embedded in C++ apps I'm using Markup::XamlReader::Load to dynamically load XAML files. This works perfectly fine with external files...
2
by: steve | last post by:
I have the following routine for retrieving error message strigs from a resource file which is embedded in the project. But when it is called I get the error messsage "Could not find any...
0
by: raylopez99 | last post by:
I have a minor problem locating an image file to load as a Bitmap. A resource file "NudeSusan.jpeg" (which I think is actually a bmp file, originally taken from a jpeg of model Susan Spears) is...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.