Home All Groups Group Topic Archive Search About

Re: Share one common imagelist amongst many forms

Author
22 Nov 2004 3:26 AM
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. :=)

Show quote
> 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.
>

Author
6 Dec 2004 8:11 PM
moondaddy
Thanks!  Look like what I was looking for.

--
moondaddy@nospam.com
Show quote
"Matt Berther" <mbert***@hotmail.com> wrote in message
news:6188713632366656228495186@news.microsoft.com...
> 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. :=)
>
> --
> Matt Berther
> http://www.mattberther.com
>
>> 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.
>>
>
>

AddThis Social Bookmark Button