TreeNode.PrevVisibleNode 属性

定义

获取上一个可见树节点。

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

属性值

TreeNode,表示上一个可见的树节点。

属性

示例

下面的代码示例在确定是否TreeNode选择了传入的 以及要选择哪个TreeNode之后选择相应的 TreeNode 。 此示例要求具有 一个 FormTreeView 包含多个 TreeNode 对象的 控件TreeNodeCollection的 。 它还要求具有 ComboBox 具有以下项的 :“Previous”、“PreviousVisible”、“Next”、“NextVisible”、“First”和“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

注解

PrevVisibleNode可以是子级、同级节点,也可以是另一个分支中的树节点。 如果没有以前的树节点,则 PrevVisibleNode 属性返回 null

适用于

另请参阅