Results 1 to 2 of 2

Thread: Keypress

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    18

    Keypress

    In my VB.NET Form, I have TextBox1, TextBox2, TextBox3, ComboBox1 and TextBox4 consecutively. I set the Form KeyPreview to True and put this code.

    Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
    If e.KeyChar = Chr(13) Then
    SendKeys.Send(vbTab)
    End If
    End Sub

    On every Textbox, every time I press Enter the focus goes to the next control. But when the focus is in the ComboBox1 and I press Enter, the focus is still on the ComboBox1.

    Do you have any solution to this problem?


    Thanks,

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    this should works fine

    VB Code:
    1. Private Sub ComboBox1_KeyPress(ByVal sender As_
    2.  Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
    3.         If e.KeyChar = Chr(13) Then
    4.             TextBox1.Focus()
    5.         End If
    6.     End Sub

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