CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2001
    Location
    Sweden
    Posts
    10

    How to change the image on a node in a treeview ctrl?

    Hi I would like to know if there is any way to change the image on an node in a treeview.
    I have all my images in an imagelist

    I would like to have a diffrent image if a parent node contains children node's or not.

    I would also like to know if this is possible to do in VBA as well - since I want to use it primery in Access 2000

    Thanks in Advance - Goftnar the Swede


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: How to change the image on a node in a treeview ctrl?

    After populating the treeview, try this:

    Dim N as Node

    for Each N In TreeView1.Nodes
    If N.Children > 0 then
    N.Image = "NodeWithChildren"
    else
    N.Image = "NodeWithoutChildren"
    End If
    next N



    Of course, there must be an image in the associated imagelist that has a key "NodeWithChildren" and one with the key "NodeWithoutChildren"

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured