TreeNode.NextVisibleNode 属性

获取下一个可见树节点。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public ReadOnly Property NextVisibleNode As TreeNode
用法
Dim instance As TreeNode
Dim value As TreeNode

value = instance.NextVisibleNode
public TreeNode NextVisibleNode { get; }
public:
property TreeNode^ NextVisibleNode {
    TreeNode^ get ();
}
/** @property */
public TreeNode get_NextVisibleNode ()
public function get NextVisibleNode () : TreeNode

属性值

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

备注

NextVisibleNode 可以是另一分支的子级、同级或树节点。如果没有下一个树节点,则 NextVisibleNode 属性返回 空引用(在 Visual Basic 中为 Nothing)。

示例

下面的代码示例确定是否已选择传入的 TreeNode 以及要选择哪个 TreeNode,然后选择适当的 TreeNode。本示例要求 Form 有一个 TreeView 控件,该控件有一个包含若干个 TreeNode 对象的 TreeNodeCollection。还要求有一个 ComboBox,它包含以下项:“Previous”、“PreviousVisible”、“Next”、“NextVisible”、“First”和“Last”。

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
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();
}
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.get_IsSelected()) {
        // Determine which TreeNode to select.
        if (myComboBox.get_Text().Equals("Previous")) {
            node.get_TreeView().set_SelectedNode(node.get_PrevNode());
        }
        else {
            if (myComboBox.get_Text().Equals("PreviousVisible")) {
                node.get_TreeView().set_SelectedNode(node.
                    get_PrevVisibleNode());
            }
            else {
                if (myComboBox.get_Text().Equals("Next")) {
                    node.get_TreeView().set_SelectedNode(node.get_NextNode());
                }
                else {
                    if (myComboBox.get_Text().Equals("NextVisible")) {
                        node.get_TreeView().set_SelectedNode(
                            node.get_NextVisibleNode());
                    }
                    else {
                        if (myComboBox.get_Text().Equals("First")) {
                            node.get_TreeView().set_SelectedNode(
                                node.get_FirstNode());
                        }
                        else {
                            if (myComboBox.get_Text().Equals("Last")) {
                                node.get_TreeView().set_SelectedNode(
                                    node.get_LastNode());
                            }
                        }
                    }
                }
            }
        }
    }
    node.get_TreeView().Focus();
} //SelectNode

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

TreeNode 类
TreeNode 成员
System.Windows.Forms 命名空间
TreeNode.IsVisible 属性
PrevVisibleNode