Results 1 to 4 of 4

Thread: Treview - Node (Parent - Root ?)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Question

    Hi,
    when using a treeview how can you tell if a specific if a specific node is a PARENT a CHILD or the ROOT NODE

    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    If the node is the root node the parent property will be nothing.

    If the node is a parent node then the parent property will be not be nothing and the child property will not be nothing.

    If the node is a child node then the child property will be nothing

    Code:
    Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    
        
        If Node.Parent Is Nothing Then
          MsgBox "ROOT"
        ElseIf (Not Node.Parent Is Nothing) And (Not Node.Child Is Nothing) Then
          MsgBox "PARENT"
        ElseIf (Node.Child Is Nothing) Then
          MsgBox "CHILD"
        End If
    
    End Sub
    Hope this helps.
    Iain, thats with an i by the way!

  3. #3
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    Post Ahhhhhh

    It seems i can't edit my posts so i will have to post again.

    Rather than testing the child property against nothing you can test the children property. This property holds the number of children a node has. If the value is 0 then it is obviously a child node.

    Code:
    Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    
        
        If Node.Parent Is Nothing Then
          MsgBox "ROOT"
        ElseIf (Not Node.Parent Is Nothing) And (Node.Children > 0) Then
          MsgBox "PARENT"
        ElseIf (Node.Children = 0) Then
          MsgBox "CHILD"
        End If
    
    End Sub
    Iain, thats with an i by the way!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Smile Thanks Alot Iain17

    Thanks Alot
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

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