Results 1 to 3 of 3

Thread: Treeview - How do I change icon on the expand?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    230

    Treeview - How do I change icon on the expand?

    The way it is set up now is that the icon changes when the node is highlighted. I only want it to change if it is expanded and changed back if it isn't. (Open folder and Closed Folder) like in Explorer.

    I don't have the same Icons for each Node so how do I set it up so it doesn't change every node just the ones I want... I only want the first Node to change to this Icon not the child of it. I want the child to change into something different if it is expanded.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    230
    this is how it is now.

    TreeView1.Nodes.Add(, , "u", "Invoices", "FoldersClosed", "FoldersOpen")

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    When you do this

    TreeView1.Nodes.Add(, , "u", "Invoices", "FoldersClosed", "FoldersOpen")

    FoldersClosed is the image and FoldersOpen is the image when the node is selected.
    If you want to change the image on Expand and/or Collapse you need to do
    VB Code:
    1. Private Sub MyTreeView_Expand(ByVal Node As MSComctlLib.Node)
    2.     Node.Image = "my expanded image"
    3. End Sub
    And similar code for the collapsed image in the Collapse event. If you only want to do it for some nodes you'll need to determine what is in Node.Key or Node.Text.

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