Share one common imagelist amongst many forms

M

moondaddy

I'm writing an app in vb.net 1.1 and would like to share one common
imagelist amongst many forms. Is there a way to do this? Perhaps put the
image list in a component and then have each form create an instance of this
component. What are some recommendations for this? I know I could put it
on a base form and inherit from that which I do for some other images, but
in this case I want to be able to choose from a few different common image
lists.

Thanks.
 
M

Matt Berther

Hello moondaddy,

class MyImageLists
{
private static ImageList imageList1 = new ImageList();

static MyImageLists()
{
// code to init imageList1
}

public static ImageList ImageList1 { get { return imageList1; } }
}

Then in your form, you can do (for example):

myListView.ImageList = MyImageLists.ImageList1;

I use a similar technique for all of my shared images. 1 Images class with
static accessors to the images. Works like a champ. :=)
 

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

Top