private void password_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (ProgramData.checkPassword(password.Text) > 0) { e.Handled = true; DialogResult = DialogResult.OK; Close(); return; } password.ForeColor = Color.Red; } else { password.ForeColor = Color.Black; } }