469,898 Members | 1,593 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

ImageList Images Disappearing

Hi,

I have a ImageList containing 4 bitmaps attached to a UserControl
which acts as a Open/Close panel.

This panel, upon click, switches the image in a PictureBox control to
indicate the current panel status (Open/Close).

Problem is that in certain complex scenarios the images disappear!
from the ImageList. That is, when I call: imageList.Images[1], I get
the exception: Specified argument was out of the range of valid
values.
Parameter name: '1' is not a valid value for 'index'. And when I check
the length of the Images collection it turns out to be zero :-(

I have a faint clue regarding the cause of this problem - it may have
something to do with the visibility of the UserControl containing the
ImageList.

Has anyone seen something like that before?
Nov 16 '05 #1
2 2852
Solomon,

I am not quite sure, why ur imagelist behaves that way.

For time being you can do this,

try
{
//lets say you are trying to get a image here and for some reason
//it throws an execption
Image test = imageList.Images[1];
}
catch(Exception e)
{
//when the exception is thrown, reload the imagelist from resource.
this.imageList1.ImageStream =
((System.Windows.Forms.ImageListStreamer)(resource s.GetObject("imageList1.Im
ageStream")));

}

--
Shak
(Houston)


"A. Solomon" <ar***@nice.com> wrote in message
news:b4************************@posting.google.com ...
Hi,

I have a ImageList containing 4 bitmaps attached to a UserControl
which acts as a Open/Close panel.

This panel, upon click, switches the image in a PictureBox control to
indicate the current panel status (Open/Close).

Problem is that in certain complex scenarios the images disappear!
from the ImageList. That is, when I call: imageList.Images[1], I get
the exception: Specified argument was out of the range of valid
values.
Parameter name: '1' is not a valid value for 'index'. And when I check
the length of the Images collection it turns out to be zero :-(

I have a faint clue regarding the cause of this problem - it may have
something to do with the visibility of the UserControl containing the
ImageList.

Has anyone seen something like that before?

Nov 16 '05 #2
The images are populated into the imagelist during the initialization... if
you run any functions in the constructor before the imagelist has had a
chance to populate, then you may see this error.

I can't think of any other reason why you'd see this error at present...

--
John Wood
EMail: first name, dot, second name at priorganize.com
"A. Solomon" <ar***@nice.com> wrote in message
news:b4************************@posting.google.com ...
Hi,

I have a ImageList containing 4 bitmaps attached to a UserControl
which acts as a Open/Close panel.

This panel, upon click, switches the image in a PictureBox control to
indicate the current panel status (Open/Close).

Problem is that in certain complex scenarios the images disappear!
from the ImageList. That is, when I call: imageList.Images[1], I get
the exception: Specified argument was out of the range of valid
values.
Parameter name: '1' is not a valid value for 'index'. And when I check
the length of the Images collection it turns out to be zero :-(

I have a faint clue regarding the cause of this problem - it may have
something to do with the visibility of the UserControl containing the
ImageList.

Has anyone seen something like that before?

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by MB | last post: by
2 posts views Thread by Michael C | last post: by
7 posts views Thread by Andrew Christiansen | last post: by
4 posts views Thread by Just Me | last post: by
2 posts views Thread by senfo | last post: by
2 posts views Thread by =?Utf-8?B?S2VuTg==?= | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.