2 imageLists; no Icons visible in ListView (VB.net 2003)

B

bonkers

Yet another bizarre one...

I have a ListView populated with images from an Image List. When the user
selects one of these images, I wish to show an enlarged image in a
PictureBox.

The only way I have managed to do this so far, is to create two ImageLists,
one with the images at 16x16, and another with the images at 140x140. The
ListView's LargeIcon and SmallIcon lists are both from ImageList1.

When the ListView selection changes, it fires an event that captures the
index of the selection, and uses that to set the PictureBox.Image to an
image with the same index -- from ImageList2.

Problem is, for some reason, the ListView no longer displays the icons when
I use LargeIcon view. If I delete ImageList2, the icons show.

Just for the halibut, I tried changing the order of the object declarations
in the form's code. Didn't do anything for me, but I suppose it was worth a
try. I thought maybe imagelist2 was initializing after ImageList1 and
confusing things.

I also tried naming ImageList2 something completely different, and I tried
populating it with copies of the images from a different folder.

So

1) is there a simpler way to get the image that I want to display in the
PictureBox, a way that doesn't involve having two imageLists?

2) Has anyone come across this issue before and found a solution?

Thanks in advance,
Rissa
 
E

Elisa

Hi,

ImageLists are probably one of the most buggy components in the current
..NET CF release. I think whoever wrote the ImageList code used
static/shared methods and variables all over the place, in an effort to
safe resources (memory), but the attempt failed misserably...

First of all, for showing pictures in a PictureBox, you should opt for
loading an image as a resource or as a file, instead of loading them
from an ImageList.

Secondly, if you notice disappearing icons in a ListView you could try
to re-assign the ImageList to the ListView. This is usually a necessary
workaround after showing another form that also uses an ImageList.


Regards,

Elisa
 
R

Rissa Karpoff

Thanks, Elisa!

Being a newbie to this environmnet, I have yet to figure out how to use
"resources"

However, since there are only a few images, and their file-size is
small, I wouldn't object to copying them to the device.....

BUT, I have not been able to figure out how to assign the external .jpg
to the PictureBox.Image, would anyone be able to help me there?

thanks, again,
Rissa
 

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

Similar Threads


Top