If you want to do something when focus is on textbox and and user press ‘Enter’ key, do the following way:
private void txt1_KeyPress(object sender, KeyPressEventArgs e)</code>
{
if (e.KeyChar == (char)Keys.Enter)
{
//do something
}
}
where txt1 is textbox
