Node.Level property. E.g. in NodeClick event.
VBCCR
Code:
#If VBA7 Then
Friend Property Get FNodeLevel(ByVal Handle As LongPtr) As Long
#Else
Friend Property Get FNodeLevel(ByVal Handle As Long) As Long
#End If
If TreeViewHandle <> NULL_PTR Then
Dim hItem As LongPtr, Count As Long
hItem = SendMessage(TreeViewHandle, TVM_GETNEXTITEM, TVGN_PARENT, ByVal Handle)
Do While hItem <> NULL_PTR
Count = Count + 1
hItem = SendMessage(TreeViewHandle, TVM_GETNEXTITEM, TVGN_PARENT, ByVal hItem)
Loop
FNodeLevel = Count
End If
End Property