473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Dynamic Resource Naming

Hello,

Im a c# noob,

How do I Change this:

this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 00;
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 01;
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 02;

To This

for (int c = 0; c < pictureBox.Count; c++)
{
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 0+c;
}

Thanks Again !

Nov 16 '06 #1
2 12412
Hi,

If the WindowsApplication1.Properties.Resources property was created for you
by VS 2005 then the following code should work for you (Note: you probably
don't need the global alias qualifier either so don't use it unless you're
absolutely sure it's necessary):

for (int c = 0; c < pictureBox.Count; c++)
{
this.pictureBox[c].Image =
(Image) Properties.Resources.ResourceManager.GetObject("_0 " + c);
}

BTW, you might want to choose a more descriptive naming convention than "_NN".
Try something like, "AnimalPictureNN", where NN is the number. I acknowledge
that might not be possible in your situation :)

--
Dave Sexton

"TheLostLeaf" <er**@canyondigital.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Hello,

Im a c# noob,

How do I Change this:

this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 00;
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 01;
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 02;

To This

for (int c = 0; c < pictureBox.Count; c++)
{
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 0+c;
}

Thanks Again !

Nov 17 '06 #2
Works Perfect !!! and saved me tons of code !

Much Thanks !

Dave Sexton wrote:
Hi,

If the WindowsApplication1.Properties.Resources property was created for you
by VS 2005 then the following code should work for you (Note: you probably
don't need the global alias qualifier either so don't use it unless you're
absolutely sure it's necessary):

for (int c = 0; c < pictureBox.Count; c++)
{
this.pictureBox[c].Image =
(Image) Properties.Resources.ResourceManager.GetObject("_0 " + c);
}

BTW, you might want to choose a more descriptive naming convention than "_NN".
Try something like, "AnimalPictureNN", where NN is the number. I acknowledge
that might not be possible in your situation :)

--
Dave Sexton

"TheLostLeaf" <er**@canyondigital.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Hello,

Im a c# noob,

How do I Change this:

this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 00;
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 01;
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 02;

To This

for (int c = 0; c < pictureBox.Count; c++)
{
this.pictureBox[c].Image =
global::WindowsApplication1.Properties.Resources._ 0+c;
}

Thanks Again !
Nov 18 '06 #3

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

Similar topics

1
by: Parham | last post by:
Hello VB compiler generate resource name by appending the resource file name to the project default namespace but C# compiler append resource file Folder name to the default namespace and then...
6
by: alexandre damiron | last post by:
Did anyone tried dynamic variable naming in Js, like the ${$varname} feature of PHP ? It would easier a long DOM generation, for example to place such a code portion into a loop .... ...
2
by: Joey Lee | last post by:
Hi, Microsoft provided some naming conventions for namespace, classes, properties and etc. However I am looking for naming convention for keys in resource files for multiple languages. Any...
8
by: Jason | last post by:
In my ASP.NET 1.1 solutions, I created several web projects and compiled them each into an assembly. The assembly names reflected the functionality of the feature (Membership.dll, Dues.dll, etc)....
1
by: Dirc Khan-Evans | last post by:
I am trying to localise my app using embedded resource and sattellite assemblies. I can get it working using the following if I have a resource file with the same name as the class: ...
0
by: Mark Sandfox | last post by:
Not sure what direction to go here, but this is what I want to accomplish. I am writing a program that I wanted to be updtable in the following matter. The main code will remain intact, but I...
3
by: TheLostLeaf | last post by:
How do I change this : this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox3 = new...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
0
by: ThoraD | last post by:
I am just trying to find out how to do things so I have some shapes in generic.xaml and the same shapes in luna.metallic.xaml with a different color. I can load them as a dynamic resource in xaml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.