Hi there people. Of all things I'm having problems making a lousy slideshow type program.
First off, I've deleted the code I've made in frustration so don't ask for any :)
I imported my pictures into the resx file and know how to access them individually but what I'm trying to do is to simply make back and next buttons.
I can't seem to figure out how to get the pictures from the resource file to a string array so I can call it with an int (Picarray
).
I've tried many things, now I'm just looking for a link or project that has one already built so I can learn by example, anyone got a link like that
I have Google'd for it (sorry Microsoft
) and found nothing I was looking for.
Remember, I want to use them from resources, not external files!
Thanks,
</NotSoProNovice>

A nifty but NOT working image slideshow (from resources)
dwebb
Since you already know the names of your images, you can create the array yourself. Then use the ResourceSet.GetObject method to lookup the resource based on the string key (internally it's a hashtable).
Two points that are not well-documented yet:
1) Add the resources using the Resources Pane in Project Designer. (In Solution Explorer, right click on the Properties node under your project, then click on "Open". ) (The docs say you can also use the Project > Add Existing Item to add a resource, but this doesn't seem to add the files to the resx file or the Resources class.)
2) The Resources class (in Resources.Designer.cs) is in a separate namespace--<projectName>.Properties, so to access the resources from your form you must either use the fully qualified name, or else add a using <projectName>.Properties statement to your "Form1" cs file.
public
partial class Form1 : Form{
string[] pics = new string[4]; ResourceSet rs; int currentPos = -1; public Form1(){
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e){
//jpgs from c:\windows\help\tours\htmltour
pics[0] =
"end_up";pics[1] =
"folder_up";pics[2] =
"gradient";pics[3] =
"icon_up"; CultureInfo ci = CultureInfo.InstalledUICulture;rs =
Resources.ResourceManager.GetResourceSet(ci, true, true);}
private void NextButton_Click(object sender, EventArgs e){
if ((pics.Length - 1) == currentPos){
currentPos = 0;
}
else{
currentPos++;
}
pictureBox1.Image = (
Bitmap) rs.GetObject(pics[currentPos]);}
}
Hope this helps.Michael Blome
Visual C# Documentation Team
landre3567
I'm sure it'll work, thanks for posting it, very much appreciate it.
All of this is just so I can familiriaze (excuse the spelling) with using resources in whole.
So much nicer using items in resource files instead of having to reference to a file which may be accidentally deleted on user side (blip error lol).
Thanks again for your reply,
Rob Sitter