Hi all,
I am trying to trap the Enter key in my form. My form contains a textbox and many buttons. The enter key will click whatever button was last selected by default.
I tried to use:
but it does not work. When i tried MyBase.KeyUp instead, it does catch it, and process the 2 statements, but only AFTER it has already processed the default keydown (button perform click) on whatever was selected.Code:Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = Keys.Enter Then btnEqual.PerformClick() MsgBox("You've pressed the Enter key") End If End Sub
I have done quite a bit of searching, and still can't figure it out. Any help would be appreciated!




Reply With Quote