ImageList must be initialized

W

What-a-Tool

Have images stored in an imagelist that I want to place in a treeview
control.
Keep getting the message "Image list must be initialized"

Can anyone direct me to a code sample of this?
Can't seem to find anything. I have already added the images that I want
thru the "custom properties" property window.

Thanks

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
K

keepITcool

the error message means you need to bind..
it's simple...

Private Sub UserForm_Initialize()
Set Me.TreeView1.ImageList = Me.ImageList1
End Sub

then in your tv s'thin like

TreeView1.Nodes.Item(Index).Image = 2



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
W

What-a-Tool

Set Me.TreeView1.ImageList = Me.ImageList1 :gives an error "Invalid object"


--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
K

keepITcool

If you cant solve THAT ..
it may be best to forget using a treeview.,
as I seriously doubt you're going to be able to fill it,
and write proper handling code for the results.


I assumed:
you have a userform..
uf has 1 treeview
uf has 1 imagelist

iml has 2 images (16X16 256 bitmaps or icons)



Private Sub UserForm_Initialize()
With Me.TreeView1
.ImageList = Me.ImageList1
.Nodes.Add , , "key1", "text1", 1
.Nodes.Add , , "key2", "text2", 2
End With
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
W

What-a-Tool

Yeah - I have a form, I have a treview on it, I have an image list on it ,
and I've got the names straight.
I have my tree view working just fine, thank you. This friggin image list is
drivin me nuts, though.

With Me.tvwMain
Set .ImageList = ilstMain
Set tn = .Nodes.Add(, , strSWDefaultFolder, strFolder, 1, 2)
End With

If I put the Me identifier in front of ilstMain, I get an Invalid Object
error.
If I test as is, I get an "imagelist must be initialized" error

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
K

keepITcool

you're using

option EXPLICIT ?

you have a Microsoft ImageList Control 6.0 (SP6)
on the form?

you have a Reference to :
Microsoft Windows Common Controls 6.0 (SP6)
(c:\windows\system32\mscomctl.ocx)

(service pack should not be a problem..)


if it's on the form then

typing me.

should popup the controls on the form..
the ilstMain MUST be there!



you've put some icons in the imagelist?
via properties..custom you;ll get the property bag.
Tab 1 must indicate 16x16!
Tab 2 you must add the icons or bitmaps.
16x16 pixels 256 color (or 24 bit)




keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
W

What-a-Tool

Ha - Got it figured out - I'm only half as dumb as I was starting to think!

Sorry- I failed to mention that this was a cross post - I wasn't coding this
in Excel. I was thinking of this as a purly VBA question, and there is a lot
of VBA know-how in this group, and the SolidWorks group couldn't help me, so
I thought I might find help here. Just wasn't giving you all the required
info, I suppose.

Had to code in an API call to "mscomctl.ocx".

Drove me nuts - the objects were all there for me, just that nothing worked
the way it was supposed to!

Thanks for the help, and sorry about the cross post


--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top