referring to imagelists

  • Thread starter Thread starter Doug Glancy
  • Start date Start date
D

Doug Glancy

How can I refer to the imagelists in a form? Something along the lines of:

dim imglist as Imagelist
For Each imglist in Me.Imagelists <----- except this doesn't exist

Thanks in advance,

Doug
 
Hello Doug,

It works like this:

Dim c As Control
Dim imgL As ImageList

For Each c In Me.Controls
If TypeOf c is ImageList Then
imgL = CType(c, ImageList)
'... Your code here ...
End If
Next

Best regards,

Martin
 
Martin H. said:
It works like this:

Dim c As Control
Dim imgL As ImageList

For Each c In Me.Controls
If TypeOf c is ImageList Then
imgL = CType(c, ImageList)
'... Your code here ...
End If
Next

Are you sure this works? ImageList is a component, not a control class.
 
Herfried K. Wagner said:
Are you sure this works? ImageList is a component, not a control class.

Herfried,

You are correct. I had tried that and it doesn't work, because the
imagelists are not among the controls. Any ideas?

Thanks,

Doug
 
Hello Doug,

This code now works. Tested!

Dim t As Integer
Dim iL As ImageList
For t = 0 To Me.components.Components.Count - 1
If TypeOf Me.components.Components(t) Is ImageList Then
iL = Me.components.Components(t)
Debug.WriteLine(iL.ToString)
End If
Next

Best regards,

Martin
 
Martin,

Thanks. I had gotten to something similar, but was still not able to
identify the ImageLists. For some reason the Name property is not
available. I just realized that I could use the Tag property, so now I can
actually tell which list is which, e.g.:

Debug.WriteLine(iL.Tag)

Thanks for your help.

Doug
 
Doug Glancy said:
I had gotten to something similar, but was still not able to identify the
ImageLists. For some reason the Name property is not available.

The "(Name)" property shown in the properties window is actually not a
property. It's the name of the private member variable generated for the
component.
 
Back
Top