ImageList - extract Images from code

Hi!

On a form I have an ImageList control named "ImageList"
I have added two images to it, and set it's keys to "Image1" and "Image2"
How do I set my form's Icon property "Image2" from this ImageList control?

I have tried the following, but it doesn't work:

'--------------------------------------------
Private Sub MDIForm_Load()
    Set Me.Icon = ImageList.ListImages.Item(2).Picture
End Sub
'-------------------------------------------

But I get "Invalid Property Value"

Thanks!
LVL 11
dbrckoviAsked:
Who is Participating?
 
fds_fatboyConnect With a Mentor Commented:
Now I can - You are using a bitmap in your list image - try this:
    Me.Icon = ImageList1.ListImages.Item(2).ExtractIcon
0
 
fds_fatboyCommented:
Remove Set.

Private Sub MDIForm_Load()
    Me.Icon = ImageList.ListImages.Item(2).Picture
End Sub
0
 
fds_fatboyCommented:
Actually it's odd - so far I can't replicate your problem - with set or not.
0
 
dbrckoviAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.