Understanding ImageList

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

If I add an image to an imagelist using

imageList.Images.Add...

And want to use it with a tree node

tn.ImageIndex = imageIndex

How do I know what to set imageIndex to?



If I want to add Images to an ImageList in some random fashion, say item 2,
then 0, then 1. How do I do that?



Thanks for any help
 
Just Me said:
If I add an image to an imagelist using

imageList.Images.Add...

And want to use it with a tree node

tn.ImageIndex = imageIndex

How do I know what to set imageIndex to?

tn.ImageIndex = imageList.Images.Count-1

or

tn.ImageIndex = imageList.Images.IndexOf(myImage)
If I want to add Images to an ImageList in some random fashion, say item 2,
then 0, then 1. How do I do that?

You will need to add a bunch of dummy to fill the collection to the desired
size and then replace those with the images in question. However it sounds
like you'd be using the collection incorrectly. Why is the order important?

Richard
 
How do I know what to set imageIndex to?
tn.ImageIndex = imageList.Images.Count-1
This is what I do

tn.ImageIndex = imageList.Images.IndexOf(myImage)
But I realized I didn't know a general way, like this
But is myimage simply the Icon I added to the list???
THANKS


Using it with a TreeView for a Windows Explorer like app. Each time I open
a directory I get the icons for the files and add them to the Imaglist.
However, I don't like the idea that the list keeps growing. If myimage above
is really just the icon I can use the above to see if it is already in the
list. Comment?



Does the imagelist actually stores the image?

If so, do you think it has to compare the bits to find the index given an
icon?

Thanks again
 

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

Image index. 1
Tough ImageList Question 4
ListView and ImageList/ImageKey 5
imagelist and treeview 1
treeview and imagelist 1
ListViewItem 1
ListView images will not show! 1
vb.net animated gif 4

Back
Top