Compartilhar via


TreeNode.PrevNode Propriedade

Definição

Obtém o nó de árvore irmão anterior.

public:
 property System::Windows::Forms::TreeNode ^ PrevNode { System::Windows::Forms::TreeNode ^ get(); };
public System.Windows.Forms.TreeNode PrevNode { get; }
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.TreeNode PrevNode { get; }
member this.PrevNode : System.Windows.Forms.TreeNode
[<System.ComponentModel.Browsable(false)>]
member this.PrevNode : System.Windows.Forms.TreeNode
Public ReadOnly Property PrevNode As TreeNode

Valor da propriedade

TreeNode

Um TreeNode que representa o nó de árvore irmão anterior.

Atributos

Exemplos

O exemplo de código a seguir seleciona o apropriado TreeNode depois de determinar se a TreeNode entrada passada está selecionada e qual TreeNode selecionar. Este exemplo requer que você tenha um Form controle com TreeView um TreeNodeCollection que contenha vários TreeNode objetos. Também requer que você tenha um ComboBox com os seguintes itens: "Anterior", "PreviousVisible", "Next", "NextVisible", "First" e "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();
}
private void SelectNode(TreeNode node)
{
    if(node.IsSelected)
    {
        // Determine which TreeNode to select.
        switch(myComboBox.Text)
        {
            case "Previous":
                node.TreeView.SelectedNode = node.PrevNode;
                break;
            case "PreviousVisible":
                node.TreeView.SelectedNode = node.PrevVisibleNode;
                break;
            case "Next":
                node.TreeView.SelectedNode = node.NextNode;
                break;
            case "NextVisible":
                node.TreeView.SelectedNode = node.NextVisibleNode;
                break;
            case "First":
                node.TreeView.SelectedNode = node.FirstNode;
                break;
            case "Last":
                node.TreeView.SelectedNode = node.LastNode;
                break;
        }
    }
    node.TreeView.Focus();
}
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

Comentários

O PrevNode é o irmão TreeNode anterior no TreeNodeCollection armazenado na Nodes propriedade do pai TreeNodedo nó de árvore. Se não houver nenhum nó de árvore anterior, a PrevNode propriedade retornará null.

Aplica-se a

Confira também