I,mageList and TreeView

Posted on 1999-11-03
Medium Priority
Last Modified: 2008-02-01
I got a simple but nasty problem for your!

I'm using VB5.0 and I got a Treeview in which I want to add an image to all of  the nodes. so I add an imagelist to the program. But i can't see the imagelist1 under (general)... (i don't know what the (Edited by Copmuter101) is called). I follow a book for the code following:

Private Sub Form_Load()
    Dim Node1 As Node
    Dim Node2 As Node
    Dim Node3 As Node
    Set Node1 = TreeView1.Nodes.Add
    TreeView1.Nodes(1).Text = "Node 1"
    TreeView1.Nodes(1).Key = "Node 1"
    TreeView1.Nodes(1).Image = "closed"
    Set Node2 = TreeView1.Nodes.Add("Node 1", tvwChild, "Node 2")
    TreeView1.Nodes(2).Text = "Node 2"
    TreeView1.Nodes(2).Key = "Node 2"
    TreeView1.Nodes(2).Image = "leaf"
    Set Node3 = TreeView1.Nodes.Add("Node 1", tvwChild, "Node 3")
    TreeView1.Nodes(3).Text = "Node 3"
    TreeView1.Nodes(3).Key = "Node 3"
    TreeView1.Nodes(3).Image = "leaf"
End Sub

I have initialised the imagelist by right clicking on the imagelist object and choosing properties. I key in the key with leaf and closed.
I insert the pictures in the directory
d:\program files\microsoft visual studio\common\graphics\bitmaps\outline\closed.bmp and leaf.bmp

But it is always back with the error saying that my imagelist hasn't been initialised (err code: 35613)

Question by:whluk
LVL 43

Accepted Solution

TimCottee earned 100 total points
ID: 2179458
Add the line
Set TreeView1.ImageList = ImageList1
Before creating the nodes. The Imagelist is not associated with the treeview unless you do it in the treeview properties or in code like this.

Author Comment

ID: 2180547
'Invalid object' comes up this time

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question