TreeNode::NextVisibleNode Property

 

Gets the next visible tree node.

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

public:
[BrowsableAttribute(false)]
property TreeNode^ NextVisibleNode {
	TreeNode^ get();
}

Property Value

Type: System.Windows.Forms::TreeNode^

A TreeNode that represents the next visible tree node.

The NextVisibleNode can be a child, sibling, or a tree node from another branch. If there is no next tree node, the NextVisibleNode 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
Return to top
Show: