none
ENTER on COMBOBOX RRS feed

  • Question

  • Hi All

    In a WnForm I have a combobox bound to a datatable and  other textboxes

    I select an item on combobox and then I press Enter but I get a beep and the cursor does not move to next tabstop

    I do not understand why. And what is the solution ?

    Thursday, November 29, 2018 8:27 PM

Answers

  • Hi,

    You can use Tab to switch focus,

        Private Sub ComboBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox1.KeyPress
            If e.KeyChar = ChrW(13) Then
                SendKeys.Send("{Tab}")
            End If
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Claudio111 Saturday, December 1, 2018 9:08 AM
    Friday, November 30, 2018 8:28 AM

All replies

  • Hello,

    Try the following.

    Public Class Form1
        Private Sub ComboBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles ComboBox1.KeyDown
            If e.KeyCode = Keys.Enter Then
                SelectNextControl(ComboBox1, True, True, True, True)
                e.Handled = True
                e.SuppressKeyPress = True
            End If
        End Sub
    End Class
    


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, November 29, 2018 11:39 PM
    Moderator
  • Hi,

    You can use Tab to switch focus,

        Private Sub ComboBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox1.KeyPress
            If e.KeyChar = ChrW(13) Then
                SendKeys.Send("{Tab}")
            End If
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Claudio111 Saturday, December 1, 2018 9:08 AM
    Friday, November 30, 2018 8:28 AM