|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Referencing Images...Normally, I would load the images into an ImageList control and use them from there (these are going to be icons). However, I need to be able to add/delete images from this image 'store' (whatever I end up using); but because an image list only allows referencing by image number in the list, when I would delete an image/icon it would 'mess' up the ones following that because obviously the image number would change. Also, I want to allow the user to load custom images/icons of their own, which again (especially when deleting images) would allow things to get screwed up because the image number would be affected (i.e. in the program I would allows my main database records to 'store' the key to an image - if that key is simply the image number in the image list, then it is going to be incorrect if any image before that gets deleted). In the old VB 6 ImageList one could assign each image a 'key' - but that isn't used in the new .NET image list. There has got to be a way to store some kind of unique key to an image and then use that key (perhaps a hash list or something). Anyone got a good way to handle this? THanks in advance. Chimp -- You can use a Dictionary to do this, assigning some key and storing Images:
Imports System.Collections.Generics .... Private m_Images As New Dictionary(Of Integer, Image) .... .... Images .Add ( 21, theImage ) .... .... myImage = Images ( 21 ) .... .... Images .Remove ( 21 ) .... .... Show quoteHide quote "Tom" <tom@nospam.com> wrote in message news:ewY3RsqfGHA.4276@TK2MSFTNGP03.phx.gbl... >I need to be able to reference some images stored in my VB.NET program. > Normally, I would load the images into an ImageList control and use > them from there (these are going to be icons). However, I need to be > able to add/delete images from this image 'store' (whatever I end up > using); but because an image list only allows referencing by image > number in the list, when I would delete an image/icon it would 'mess' > up the ones following that because obviously the image number would > change. Also, I want to allow the user to load custom images/icons of > their own, which again (especially when deleting images) would allow > things to get screwed up because the image number would be affected > (i.e. in the program I would allows my main database records to 'store' > the key to an image - if that key is simply the image number in the > image list, then it is going to be incorrect if any image before that > gets deleted). > > In the old VB 6 ImageList one could assign each image a 'key' - but > that isn't used in the new .NET image list. There has got to be a way > to store some kind of unique key to an image and then use that key > (perhaps a hash list or something). Anyone got a good way to handle > this? THanks in advance. > > Chimp > > -- >
Show quote
Hide quote
On Tue, 23 May 2006 13:54:21 -0700, "Tom" <tom@nospam.com> wrote: If you manage to add images in Design to an ImageList componet>I need to be able to reference some images stored in my VB.NET program. >Normally, I would load the images into an ImageList control and use >them from there (these are going to be icons). However, I need to be >able to add/delete images from this image 'store' (whatever I end up >using); but because an image list only allows referencing by image >number in the list, when I would delete an image/icon it would 'mess' >up the ones following that because obviously the image number would >change. Also, I want to allow the user to load custom images/icons of >their own, which again (especially when deleting images) would allow >things to get screwed up because the image number would be affected >(i.e. in the program I would allows my main database records to 'store' >the key to an image - if that key is simply the image number in the >image list, then it is going to be incorrect if any image before that >gets deleted). > >In the old VB 6 ImageList one could assign each image a 'key' - but >that isn't used in the new .NET image list. There has got to be a way >to store some kind of unique key to an image and then use that key >(perhaps a hash list or something). Anyone got a good way to handle >this? THanks in advance. > >Chimp (doesn't work, here), you should be able to add keys at runtime: ImageList1.Images.SetKeyName(index, "SomeKey") By your description, it may better to simply populate the ImageList at runtime: ImageList1.Images.Add("SomeKey", SomeImage) To delete: ImageList1.Images.RemoveByKey("SomeKey") Gene
What's the most performant? Fat our smart client?
Postmessage API Can't get true random numbers CHRW .Net Mail and hotmail question Need to check a checkbox in a checkedlistbox at run time Searching within search results (Database) What are they? Controls do not show correctly at runtime. Getting correct copy count from Print Dialog box |
|||||||||||||||||||||||