Private sub ShowNodes(N as Node, Level as long) If Not N Is Null Then N.EnsureVisible = True If Level > 0 then ShowNodes N.Child, Level - 1 End If End Sub
Private Sub FirstNode(Level As Long) Dim nod1 As Node Dim nod2 As Node Set nod1 = TreeView1.SelectedItem Do While (nod1 Is Nothing) = False Set nod2 = nod1 Set nod1 = nod1.Parent Loop ShowNodes nod2.FirstSibling, Level End Sub Private Sub ShowNodes(N As Node, Level As Long) If Not N Is Nothing Then If Level > 1 Then N.Expanded = True ShowNodes N.Child, Level - 1 Else N.Expanded = False End If ShowNodes N.Next, Level End If End Sub