|
-
Jul 14th, 2006, 08:31 AM
#1
Thread Starter
Hyperactive Member
[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?
-
Jul 14th, 2006, 08:55 AM
#2
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:
Private _MyImageList as ImageList
Public Property MyImageList() as ImageList
Get
return _MyImageList
End Get
Set(value as imagelist)
_MyImageList = value
end set
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...
-
Jul 14th, 2006, 08:56 AM
#3
Lively Member
Re: Passing ImageList between forms
you can reference a variable from another form by passing it through subroutines: like this:
VB Code:
Sub users(ByVal imglst As ImageList)
End Sub
then reference this sub from frmMain:
frmUsers.users(imagelist1)
your imagelist will then be available on frmUsers.
-
Jul 14th, 2006, 10:18 AM
#4
Thread Starter
Hyperactive Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|