TreeNode::NextNode Property
.NET Framework (current version)
Gets the next sibling tree node.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
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".
void SelectNode( TreeNode^ node ) { if ( node->IsSelected ) { // Determine which TreeNode to select. String^ str = myComboBox->Text; if ( str->Equals( "Previous" ) ) node->TreeView->SelectedNode = node->PrevNode; else if ( str->Equals( "PreviousVisible" ) ) node->TreeView->SelectedNode = node->PrevVisibleNode; else if ( str->Equals( "Next" ) ) node->TreeView->SelectedNode = node->NextNode; else if ( str->Equals( "NextVisible" ) ) node->TreeView->SelectedNode = node->NextVisibleNode; else if ( str->Equals( "First" ) ) node->TreeView->SelectedNode = node->FirstNode; else if ( str->Equals( "Last" ) ) node->TreeView->SelectedNode = node->LastNode; } node->TreeView->Focus(); }
.NET Framework
Available since 1.1
Available since 1.1
Show: