TreeNode.NextNode Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the next sibling tree node.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

<BrowsableAttribute(False)>
Public ReadOnly Property NextNode As TreeNode

Property Value

Type: System.Windows.Forms.TreeNode

A TreeNode that represents the next sibling tree node.

The NextNode is the next sibling TreeNode in the TreeNodeCollection stored in the Nodes property of the tree node's parent TreeNode. If there is no next tree node, the NextNode property returns null.

The following code example selects the appropriate TreeNode after determining if the TreeNode passed in is selected and which TreeNode to select. This example requires that you have a Form with a TreeView control that has a TreeNodeCollection that contains several TreeNode objects. It also requires that you have a ComboBox with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last".

Private Sub SelectNode(node As TreeNode)
   If node.IsSelected Then
      ' Determine which TreeNode to select.
      Select Case myComboBox.Text
         Case "Previous"
            node.TreeView.SelectedNode = node.PrevNode
         Case "PreviousVisible"
            node.TreeView.SelectedNode = node.PrevVisibleNode
         Case "Next"
            node.TreeView.SelectedNode = node.NextNode
         Case "NextVisible"
            node.TreeView.SelectedNode = node.NextVisibleNode
         Case "First"
            node.TreeView.SelectedNode = node.FirstNode
         Case "Last"
            node.TreeView.SelectedNode = node.LastNode
      End Select
   End If
   node.TreeView.Focus()
End Sub

.NET Framework
Available since 1.1
Return to top
Show: