private void gotonumber_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)0xD) { if (gotonumber.Text == "") return; int n = 0; if (int.TryParse(gotonumber.Text, out n)) { goToNumber(n); } } }