TreeNode::IsSelected Property
.NET Framework (current version)
Gets a value indicating whether the tree node is in the selected state.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Property Value
Type: System::Booleantrue if the tree node is in the selected state; otherwise, false.
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 containing 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: