Peter,
It appears that if you set the ImageList's ImageSize property and Images collection
at design time, you won't be able to change the ImageSize without recreating the
Images collection as well.
I recommed you create a resource file, then add your images to that resource file,
then read the images from the resource (which gets embedded in your assembly)
at runtime.
Here is are great article on how to do this:
http://www.jelovic.com/articles/resources_in_visual_studio.htm
- Note, once you add the images to the resource file (using Resourcer tool)
make sure to *rename* them since the default name includes the path.
Here is the VB.NET code that I used to resize the ImageList and add
two images at runtime.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.ImageList1.ImageSize = New Size(16, 16) ' This will reset the Images collection
' Create a resource manager to retrieve images embedded in the assembly
Dim resManager As New System.Resources.ResourceManager("ImageList.Form1", _
System.Reflection.Assembly.GetExecutingAssembly())
' Add image1 to ImageList's Images collection
Dim myImage As Bitmap = CType(resManager.GetObject("Image1.jpg"), Bitmap)
Me.ImageList1.Images.Add(myImage)
' Add image2 to ImageList's Images collection
myImage = CType(resManager.GetObject("Image2.jpg"), Bitmap)
Me.ImageList1.Images.Add(myImage)
End Sub
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com