Creating an array of .Image types in a form?

  • Thread starter Thread starter Greg Merideth
  • Start date Start date
G

Greg Merideth

I've created arrays of labels, linklabels and other form items but I
can't figure out how to create an array of images in a form,
dynamically. The form page will require up to 30 images to be loaded
with the urls' coming from an xml file. I parsed out the xml easily
enough but I hope that I dont have to create 30 separate images. There
has to be a way to create an array of images.

Any ideas?
 
Hi Greg,

Please correct me if I have not understood your question correctly.

I assume you need to create an array of System.Drawing.Image objects
on the fly from a set of file path names that you have extracted
from an XML document. You can try something like the following:

String[] imageFilePaths;

// Let's assume imageFilePaths contains the file paths to the images
// that are extracted from your XML document
// Populate imageFilePaths array here from the XML doc.....

// Create an array of images
Image[] images = new Image[30];
for(int index = 0; index < 30; index++)
{
images[index] = Image.FromFile(imageFilePaths[index]);
}


Regards,
Aravind C
 
Thanks for the post. I went a little overboard from lack of sleep I
think, that solution was about 100x easier than what I was playing
around with.


Aravind said:
Hi Greg,

Please correct me if I have not understood your question correctly.

I assume you need to create an array of System.Drawing.Image objects
on the fly from a set of file path names that you have extracted
from an XML document. You can try something like the following:

String[] imageFilePaths;

// Let's assume imageFilePaths contains the file paths to the images
// that are extracted from your XML document
// Populate imageFilePaths array here from the XML doc.....

// Create an array of images
Image[] images = new Image[30];
for(int index = 0; index < 30; index++)
{
images[index] = Image.FromFile(imageFilePaths[index]);
}


Regards,
Aravind C


I've created arrays of labels, linklabels and other form items but I
can't figure out how to create an array of images in a form,
dynamically. The form page will require up to 30 images to be loaded
with the urls' coming from an xml file. I parsed out the xml easily
enough but I hope that I dont have to create 30 separate images. There
has to be a way to create an array of images.

Any ideas?
 
Back
Top