VB.NET: ListView KeyDown doesn't recognize the Enter(Return) key

I have a form with a listview in VB.NET, the ListView is focused and the form property KeyPreview is set to true. No matter what, the Enter key is never recognized in the listviews KeyDown event. How to fix that?
Private Sub lvListView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles lvListView.click
        If e.KeyCode = Keys.Enter Then
            Debug.Print("ENTER!!!")  'Never happens
        End If
    End Sub

Open in new window

Who is Participating?
Wayne Taylor (webtubbs)Connect With a Mentor Commented:
Works fine for me. Are you saying there is nothing outputted to the immediate window?
JiriNovotnyAuthor Commented:
I've figured it out. The form had AcceptButton set to a button that was not doing anything yet. Confused me :) Thanks for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.