TreeNode::FirstNode Property
.NET Framework (current version)
Gets the first child tree node in the tree node collection.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The FirstNode is the first child TreeNode in the TreeNodeCollection stored in the Nodes property of the current tree node. If the TreeNode has no child tree node, the FirstNode 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: