1

我正在使用一个树视图,其中我有许多父节点和子节点.. 在树视图 keydown 事件中,我使用以下代码在给出 keydown 和 keyup 时选择下一个节点

    Private Sub Treeview1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Treeview1.KeyDown
        If e.KeyCode = Keys.Up Then
            Treeview1.Select()
        ElseIf e.KeyCode = Keys.Down Then
            Treeview1.Select()
        End If
    End Sub

( Treeview1.Select()) Now when the selection reaches the very first node, I want to focus previous control of treeview, but I can't check the selected node is first node of treeview. 谁能帮我找到。

4

2 回答 2

5

您可以处理AfterSelect事件以找出它

Private Sub Treeview1_AfterSelect(sender As Object, e As TreeViewEventArgs)
    If e.Node = Treeview1.Nodes(0) Then
        do something
    End If
End Sub
于 2013-03-06T07:16:47.107 回答
0

您还可以检查TreeView.SelectedNodeTreeNode.PrevNodeTreeNode.NextNode

于 2013-03-06T13:20:57.660 回答