private void txtIso_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { string iso2 = txtIso.Text.ToUpper(); int newPosition = CountryArray.GetPosition(iso2); if (newPosition >= 0) { curPosition = newPosition; } else { ShowErrorDialog(iso2); } fillFields(); } }