Reputation: 11
I'm just learning C#. I created a Windows Form Application. It works, but you have to click on the "Calculate" button that I created to activate the program. I would like to be able to just hit Enter on my keyboard. I thought maybe there was a properties setting for the button but I don't see one.
Any ideas?
Upvotes: 0
Views: 99
Reputation: 21
You could listen for the KeyUp event
using System.Windows.Forms;
private void btnSubmit_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("You hit the Enter key.");
}
Upvotes: 2
Reputation: 101681
You are looking for Form.AcceptButton
property
Gets or sets the button on the form that is clicked when the user presses the ENTER key.
Upvotes: 8