Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Dynamic Resource Naming

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TheLostLeaf - 16 Nov 2006 06:13 GMT
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 !
Dave Sexton - 17 Nov 2006 13:17 GMT
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 :)

Signature

Dave Sexton

> Hello,
>
[quoted text clipped - 18 lines]
>
> Thanks Again !
TheLostLeaf - 18 Nov 2006 23:59 GMT
Works Perfect !!! and saved me tons of code !

Much Thanks !

> Hi,
>
[quoted text clipped - 38 lines]
> >
> > Thanks Again !

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.