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 :)
Printable View
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 :)
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
Hope this helps.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
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
:) Thanks Alot :)