Results 1 to 4 of 4

Thread: TreeView Questions Galore!!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121

    TreeView Questions Galore!!

    OK I have a TreeView, it works.
    1. How can I fill a combobox with the Root Nodes.
    2. Adding a child node is case sensitive (ie.
    Code:
    tvwMenu.Nodes.Add "menu", tvwChild, "help", "I need Help"
    is not the same as
    tvwMenu.Nodes.Add "Menu", tvwChild, "help", "I need Help"
    What is the best way to get around the that? (my thoughts were the combobox)
    3. How do I fill a combo box with the list of images in an ImageList?
    4. If I click and select an item in a treeview how do I detect which item is selected and delete it via a command button?

    Thanks
    Zevlag

  2. #2
    gaffa
    Guest
    Some answers ....

    1. To get all the root nodes, loop throughthe nodes collection and any node that doesn't have a parent is a root node.
    Code:
    Dim lNode as Node
    
    For Each lNode in Treeview1.Nodes
        If lNode.Parent Is Nothing then
            'This node is a root node
            Combo1.AddItem lNode.Text
        End If
    Next lNode
    2. The case sensitivity is because the first parameter when you add a node is the key of the parent node, and the keys are case sensitive. Easiest way to get around this is to force all keys to be upper case.

    3. You'll need to use the ImageComboBox to get nice pictures in a combo. It's like a treeview in its structure, but instead of nodes, it has a ComboItems collection

    4. The currently selected item can be retrieved by looking at the treeview Selected property
    Code:
    'Make sure a node is selected 
    If Not TreeView1.Selected Is Nothing then
        Treeview1.Nodes.Remove TreeView1.Selected.Key
    End if
    When removing a node, don't forget to check if that node has any child nodes (use the Children property of the node)

    - gaffa

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    Thanks

    OK lets say I wanted to list all the keys or tags of an imagelist in a combobox not the Images themselves, best way to do it is?

  4. #4
    gaffa
    Guest
    This will load the keys or the tags of all the images in an imagelist into a combo box
    Code:
        Dim lIndex As Long
        
        For lIndex = 1 To ImageList1.ListImages.Count
            'Key option
            Combo1.AddItem ImageList1.ListImages.Item(lIndex).Key
            'Tag option
            Combo1.AddItem ImageList1.ListImages.Item(lIndex).Tag
        Next lIndex
    - gaffa

    (Stuffed the code up )

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