I want to have ONE instance of an image list that I want to share over all the forms in my application(s) (icons for the toolbar). I've seen the question asked before and people came up with a user control (which is no good, since it will create multiple instances of the imagelist and thus create unnecessary objects and overhead).
Design time support would be good, but not very essential.
In Delphi this was pretty easy: create a DataForm, share the images and you are off.
Is there a C#/.Net/Winforms variantion on that?
You could simply make a static class hold an ImageList instance, and use that in your application, I guess:
public static class ImageListWrapper
{
static ImageListWrapper()
{
ImageList = new ImageList();
LoadImages(ImageList);
}
private static void LoadImages(ImageList imageList)
{
// load images into the list
}
public static ImageList ImageList { get; private set; }
}
Then you can load images from the hosted ImageList:
someControl.Image = ImageListWrapper.ImageList.Images["some_image"];
No design time support in that solution though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With