开发者

How to capture Enter Button Pressed Event

The image below shows a part of my Login 开发者_如何学运维form . The program works fine and I am able to login when I press the Enter Button. But I want to Login when I press My Enter Button (Return Button) on my Keyboard. How can I do this ?

How to capture Enter Button Pressed Event


In the properties of the form set the Accept button propertyto the Enter button which will gives your desired.


Try using

Me.AcceptButton = YourButton
YourButton.DialogResult = System.Windows.Forms.DialogResult.OK

pressing Return (on your Keyboard) will cause this Button_Click event to fire.


You could set the Form's AcceptButton to your Enter-Button. Additionally you could set it's CancelButton to your Clear-Button. That calls the clear-function to be triggered when user presses Esc-Key.

By the way, this was asked before here.


Private Sub frmcalculator_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Enter Then
            Call btnequals_Click(sender, e)
        End If
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜