Results 1 to 4 of 4

Thread: [RESOLVED] Passing ImageList between forms

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Resolved [RESOLVED] Passing ImageList between forms

    Hi,
    I have two forms frmMain and frmUsers.
    frmMain has an ImageList, and I fill that list with pics from file when program starts.
    However I need to use the pics from the ImageList on my other form.

    How can I use the ImageList from frmMain in my other form?
    Thanks

    Tomexx.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Passing ImageList between forms

    if you are using VB 2005, then you should be able to access it through the default instance of frmMain. If you are not, and using a variable instance for each form, you could simply pass the imagelist to frmUsers when you create it

    to do that you would either create a public property in frmUsers to accept the image list

    (sorry this code is all freehand...)
    VB Code:
    1. Private _MyImageList as ImageList
    2.  
    3. Public Property MyImageList() as ImageList
    4.     Get
    5.         return _MyImageList
    6.     End Get
    7.     Set(value as imagelist)
    8.         _MyImageList = value
    9.     end set
    10. end property

    if the image list being in frmUsers is ALWAYS needed, you may want to actually add it to the constructor (the New sub) instead of making it a public property.. that way you can't create an instance of the form without passing it an image list...

  3. #3
    Lively Member
    Join Date
    Jun 2005
    Location
    New Jersey, USA
    Posts
    119

    Re: Passing ImageList between forms

    you can reference a variable from another form by passing it through subroutines: like this:


    VB Code:
    1. Sub users(ByVal imglst As ImageList)
    2.  
    3.     End Sub

    then reference this sub from frmMain:

    frmUsers.users(imagelist1)

    your imagelist will then be available on frmUsers.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Re: Passing ImageList between forms

    Thanks,
    I'll did it passing the ImageList in the form constructor (just as any variable) and that seems to work.
    Thanks

    Tomexx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width