Is it possible for me to use a single image list over multiple forms? I have an image list with many little pictures which I need to use on every form and I don't want to have to create a new image list for every form. Any help appreciated.
Printable View
Is it possible for me to use a single image list over multiple forms? I have an image list with many little pictures which I need to use on every form and I don't want to have to create a new image list for every form. Any help appreciated.
If you place it on a form that will always be instanciated then yes, you can. How is your app setup, formwize?
You can also create the IL in code in a public class. Then its available to all and always instanciated if you do it at program startup.
Hmm, that might end up being a good bit of coding...Quote:
You can also create the IL in code in a public class.
So you mean that as long as the form with the image list is active, I can use its features? So does that rule out:
VB Code:
Me.Hide
On the owner form? Becasue doesn't that just make the form invisible, but still active?
That doesnt make any difference. As long as you have a public variable instanciated of your form type you can access the IL like so.
VB Code:
'In a public module Module Module1 Public goMain As New frmMain Public Sub Main() Application.Run(goMain) End Sub End Module 'Then on your frmMain form you have your IL. 'Reference the IL on other forms... Public Class frmOther Private Sub frmOther_Load(lah, Blah, blah...) Me.Label1.Image = goMain.ImageList1.Images(3) End Sub End Class
/me looks up 'instanciated' on goolgle search...
Hmm... doesn't seem to be a definition...
Anyway, thanks for the code. All my forms are decalred public so thats half the work done. Great ;)
Instance: Public goForm As New frmMain.
How are you showing your forms? Showing each one from another or sub main, etc.
How are you showing your forms? Showing each one from another or sub main, etc.
Ahh... I just use ThisForm.ShowDialog() and Me.Hide. Forms are declared as Public in MainModule so thats fine. I can use ThisForm.Show() too. I will try to code it when I get home from school ;)
Basically if you need certain forms to be always created" then you can do like I am. Then from each form or button you can do
a goSomeOtherForm.Show and goMain.Hide.