Results 1 to 3 of 3

Thread: Focus()

  1. #1

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435

    Focus()

    After selecting something from a Treeview, how do I shift focus to something else? Here's the code:
    VB Code:
    1. Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
    2.         Try
    3.             CodeDirectory = e.Node.Parent.Text
    4.             code = "code\" & CodeDirectory & "\" & e.Node.Text & ".rtf"
    5.             rtbcodewindow.LoadFile(code, RichTextBoxStreamType.RichText)
    6.         Catch ex As Exception
    7.             'MessageBox.Show(ex.Message)
    8.         End Try
    9.         [b]rtbcodewindow.Focus()[/b]
    10.     End Sub
    I thought rtbcodewindow.Focus() would automatically shift the focus to the RichTextBox called rtbcodewindow, but it doesn't.

    Anyone any ideas?
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I dunno what you mean but this works for me :
    VB Code:
    1. RichTextBox1.Focus()

  3. #3

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    You'd think so wouldn't you, nice and simple rtbcodewindow.focus(), but no. This is really for people with a mouse wheel (like myself), this is what happens:

    1/. Open a parent node
    2/. Select a child node
    3/. Chosen text appears in Code Window.

    This is what's supposed to happen
    4/. Focus jumps to Code Window (Richtextbox<rtbcodewindow>)
    5/. Flashing caret in Code Window
    6/. User uses mouse wheel to move up and down through the code.

    This is what actually happens
    4/. Focus stays on Treeview
    5/. No Flashing caret anywhere
    6/. Moving the mouse wheel moves the Treeview left and right to show out of view text.

    If I click on the Code Window, everythings ok, but otherwise I can't get the focus on the richtextbox
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

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