Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imagelist

Status
Not open for further replies.

shaunhubbs

Technical User
Jun 6, 2005
57
CA
Hi all,

I am trying to add icons beside nodes in my treeview and am not able to do so with the following code:

Code:
    Do Until rs.EOF
        Dim imgVar As ImageList
        Form_frmSetsTree.imlIcons.ImageHeight = 16
        Form_frmSetsTree.imlIcons.ImageWidth = 16
[COLOR=red]        Set imgVar = Form_frmSetsTree.imlIcons.ListImages.Add _
            (1, "Question", LoadPicture("C:\WINDOWS\Help\Tours\htmlTour\question_icon.jpg"))[/color red]

        Dim c As Integer 'Child level
        c = rs!lvl
        Dim p As Integer 'Parent level
        p = rs!lvl - 1
        
        ' Fill the root level of the tree with set names
        If rs!lvl = 1 Then
            Form_frmSetsTree!axTreeView.Nodes.Add , , "l1" & rs!urn, RTrim(rs!Child), [COLOR=red]"Question"[/color red]
        ' Fill with a child node in the tree
        Else
            Form_frmSetsTree!axTreeView.Nodes.Add "l" & p & rs!parent_urn, tvwChild, "l" & c & rs!urn, RTrim(rs!Child)
            Form_frmSetsTree!axTreeView.Nodes("l" & c & rs!urn).Sorted = True
        End If

        rs.MoveNext
    Loop

Can anyone spot the reason for this not working? The image does definitely exist...

Thanks in advance.

- Shaun
 
Hi Shaun

Unless I am misreading the code, you seem to be trying to assign a ListImage object to a ImageList (imgvar)

As you are not using imgvar elsewhere in the code you provide, wouldn't it be easier to simply call the Listimages.Add method without assigning the result to a variable ?
Or maybe you could simply add the "Question" icon at design time ?

HTH

Droops
 
Oops,

I missed out the first line of code.

Even if you add the Listimage to the ImageList.ListImages collection, you should run into a "Duplicate Key" or "Duplicate Index" error as the Add method is called within a Loop and you have fixed the Index to 1 and Key to "Question".


Droops
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top