ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ImageList must be initialized (https://www.excelbanter.com/excel-programming/314205-imagelist-must-initialized.html)

What-a-Tool

ImageList must be initialized
 
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)



keepITcool

ImageList must be initialized
 
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


"What-a-Tool" wrote:

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



What-a-Tool

ImageList must be initialized
 
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)

"keepITcool" wrote in message
...
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


"What-a-Tool" wrote:

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





keepITcool

ImageList must be initialized
 


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


"What-a-Tool" wrote:

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




What-a-Tool

ImageList must be initialized
 
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)

"keepITcool" wrote in message
...


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


"What-a-Tool" wrote:

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






keepITcool

ImageList must be initialized
 
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


"What-a-Tool" wrote:

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



What-a-Tool

ImageList must be initialized
 
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)

"What-a-Tool" wrote in message
news:QlBdd.33366$cN6.26387@lakeread02...
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)






All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com