-
I want to navigate through a treeview with the keyboard while the focus is on another control (a textbox)..
When I hit vbkeyup I want to goup an item
when I hit vbkeydown I want to go down an item... I thought of the following code:
Code:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo EOF_Error
Select Case KeyCode
Case vbKeyDelete
m_bEditFromCode = True
Case vbKeyBack
m_bEditFromCode = True
Case vbKeyUp
' tvwTree.SetFocus
tvwTree.SelectedItem.Previous.Selected = True
Case vbKeyDown
' tvwTree.SetFocus
tvwTree.SelectedItem.Next.Selected = True
End Select
EOF_Error:
If Err.Number = 91 Then Resume Next
End Sub
This does not work completely because it will never exit the root node... It will only go up or down within the same path
How can I accomplish to make it go up an item when I hit vbkeyup and down an item when I click vbeydown ??
-
Try this for the Up logic
MyTreeview.SelectedItem = MyTreeview.Nodes(MyTreeview.SelectedItem.Index - 1) and similar with + 1 for down.
------------------
Marty
-
This works but there's one problem..
If it reaches a Node with children this code will expand this node and go to the children of the node... I don't want that.
It should behave like a treeview behaves that has the focus:
Up and down key for navigation between visible nodes...
[This message has been edited by Inhumanoid (edited 11-25-1999).]