Kieron Posted February 18, 2003 Posted February 18, 2003 (edited) Hi, I've got all of the icons i'm using in one DLL (makes them easy to update should i need to), I've then got three projects (part of the one solution) using this file to retrieve the icons...this means that all my icon associations are in code, not in the UI. Is there any way of using a Key property like the ImageList in VB6 instead of this terrible index only thang?? Regards Kieron Edited February 18, 2003 by divil Quote
TechnoTone Posted February 18, 2003 Posted February 18, 2003 I don't think you can have a key but you could create an enumeration to make your coding nicer. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
Cywizz Posted February 18, 2003 Posted February 18, 2003 I don't know how you currently retrieve the icons out of the dll, but if you use the 'Assembly.GetManifestResourceStream' method, you must specify a full namespace + filename for the required icon. Will this be a sufficient key? Quote Howzit??
*Experts* Volte Posted February 18, 2003 *Experts* Posted February 18, 2003 You could always add the images to an ArrayList that you create yourself, rather than using an ImageList. Unless you are binding the ImageList to a control which requires it (such as a toolbar), then I see no real need for using it like that. You could also build your own pseudo-ImageList control which allowed you to add items that did have a Key property (a class that you make yourself). Quote
Kieron Posted February 18, 2003 Author Posted February 18, 2003 I thought of an enumeration but it's a bit of a long-winded way of doing it. As for the namespace+filename, that's not really an issue - it's getting the correct index...1 isn't as meaningful as ID_Customers!! Quote
Cywizz Posted February 18, 2003 Posted February 18, 2003 My suggestion will only work if you add all the icons as embedded resource in this dll (instead of the imagelist). You can then get them out by using a key (namespace + filename) Quote Howzit??
Kieron Posted February 18, 2003 Author Posted February 18, 2003 Hi, that's what I've done...the image lists are in each form and the appropriate icons loaded from the DLL via the manifest stream. Quote
Cywizz Posted February 18, 2003 Posted February 18, 2003 Ok, so you load the icons into the imagelists @ runtime... There's one other way left, (maybe - any comments from guru's will be apreciated): Create your own imagelist control, inherited from the normal imagelist, and extend on it's 'Images' collection by adding another Indexer (overload the original one). As I was saying, the suggestion is a quick thought but you will have investigate if it's possible..... EDIT: Ok, can't - You can not inherit from a imagelist control, sorry I've tried :) Quote Howzit??
*Gurus* divil Posted February 18, 2003 *Gurus* Posted February 18, 2003 ImageLists are meant to store lots of icons that will perform the same function - for instance, you'd fill an imagelist and associate it with a toolbar if you wanted a store of images for that use. Keys were omitted because they are not necessary for this - designers show a dropdown menu of images to choose from. If you are using an ImageList as a general repository for images in your application, you might consider embedding them all as resources in your app instead. As I said, ImageLists are meant to store a group of similar images, keys would be a waste. That said, you could always use a dictionary object like a Hashtable to build a relationship of strings to images at runtime, you'd have to create a procedure and hardcode the relationships yourself. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Kieron Posted February 18, 2003 Author Posted February 18, 2003 Bugger - no matter, cheers for the help guys!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.