image list

skaryChinezeGuie

Well-known member
Joined
Apr 23, 2006
Messages
94
Programming Experience
Beginner
i finally figured out how to use an image list to display pics in a picturebox, now how do i make that imagelist accessable to all my other forms. I tried changing the "modifier" property to public but that didn't work.
 
Simply add the ImageList control to your main form and add the images you want to use in it (at design time). Then make a global variable in a Module to reference an ImageList. From the main form Load() event, set the global ImageList variable to the main form ImageList:
VB.NET:
[COLOR=#115e94][FONT=Tahoma]Imports system.Windows.Forms
 
    Module GlobalImageList
 
        Public myGlobalImageList As ImageList
 
    End Module
 
[/FONT][/COLOR]
[COLOR=#115e94][FONT=Tahoma][COLOR=darkgreen]‘then from the main form[/COLOR]
Public Class Form1
        Inherits System.Windows.Forms.Form
 
        Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
           myGlobalImageList = Me.ImageList1
        End Sub
       {...}
End Class
[/FONT][/COLOR]

Although there are other ways (for example you can add the images as embedded resources and so on) but, i prefer this.
 
Back
Top