how to add Image array / ImageList.ImageCollection to a control?

K

Kristopher Wragg

Hi,

I'm creating a customized picturebox that will have an array of images
and some properties that will allow the picturebox to change its image
to one of the images in the array depending on events that it registers
for...

I'm having trouble storing an array of images though,

I've tried Image[] but this doesn't work correctly, I've tried
ImageList.ImageCollection but this doesn't save images once you've
selected them, I've tried ShouldSerialize procedure, that didn't help.

The only thing I've got to work is adding an ImageList, but I dont
particulally want that as I want customers to be able to drop a
PictureBox onto the canvas and just set the images in the property
panal, not mess around adding an ImageList etc...

any ideas?

Thanks,
Kris Wragg
 
K

Kris Wragg

Just to add this is what I've tried so far with no luck:

private Image[] myImages;
public Image[] MyImages
{
get { return myImages; }
set { myImages = value; }
}

this returns an error when trying to add a new image in the property grid i
recieve:

"Cannot create an instance of System.Drawing.Image because it is an abstract
class."

public ImageList.ImageCollection MyImageList
{
get { return imageList.Images; }
//set { iconList.Images = value; } // this doesn't work
}

this throws an error after selecting a new image to be added and says:
"Parameter must be of type Image. Parameter name: value"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top