Results 1 to 3 of 3

Thread: Treeview navigation problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    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 ??

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    Try this for the Up logic
    MyTreeview.SelectedItem = MyTreeview.Nodes(MyTreeview.SelectedItem.Index - 1) and similar with + 1 for down.


    ------------------
    Marty

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    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).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width