Imagelists
-
Hi All, Is it possible to move image files around an ImageList during run time after the ImageList has been populated at design time? Basically i'm looking for the code syntax for being able to sort image files (*.gif) in an ImageList. Can this be done using the "index" value of the stored images? thanks
-
Hi All, Is it possible to move image files around an ImageList during run time after the ImageList has been populated at design time? Basically i'm looking for the code syntax for being able to sort image files (*.gif) in an ImageList. Can this be done using the "index" value of the stored images? thanks
There isn't any way to sort an existing ImageList. You can Add images to the end of the ImageList and RemoveAt any index in the list, but you can't "AddAt", "Insert", "Move", or "Swap". I can see a possible way to do it, but you'd end up extending the existing ImageList class and supplying the code to InsertAt or Swap. The only way I can see supporting this is making an entirely new ImageList, copying the images from the source ImageList one at a time to a new ImageList and stopping at the appropriate places to make whatever changes are needed. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
There isn't any way to sort an existing ImageList. You can Add images to the end of the ImageList and RemoveAt any index in the list, but you can't "AddAt", "Insert", "Move", or "Swap". I can see a possible way to do it, but you'd end up extending the existing ImageList class and supplying the code to InsertAt or Swap. The only way I can see supporting this is making an entirely new ImageList, copying the images from the source ImageList one at a time to a new ImageList and stopping at the appropriate places to make whatever changes are needed. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Thanks for putting me out of my misery Dave. I also had the idea of generating another imagelist but was trying to do things more compactly if possible. Do you know if there is a way of extracting the index of the image file as an integer and store it as another variable? thanks
-
Thanks for putting me out of my misery Dave. I also had the idea of generating another imagelist but was trying to do things more compactly if possible. Do you know if there is a way of extracting the index of the image file as an integer and store it as another variable? thanks
Are you syaing that you want the
.Add()
method to return the index that the image was put into?.Add()
is a sub and doesn't return a value. Since the new image is always appended to the end of the collection, you can probably use theItems.Count
property to find out what the next index is going to be before you.Add()
the image. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome