élimine la touche Entrée après l'avoir appuyée dans l'événement de saisie d'une zone de texte

StackOverflow https://stackoverflow.com/questions/236675

  •  04-07-2019
  •  | 
  •  

Question

Comment annuler un événement de frappe dans une zone de texte après avoir appuyé sur la touche de retour.

Était-ce utile?

La solution

Définissez la propriété Handled du paramètre du gestionnaire KeyPressEventArgs sur true.

Exemple tiré de msdn:

private void keypressed(Object o, KeyPressEventArgs e)
{
    if (e.KeyChar == (char)Keys.Return)
    {
        e.Handled = true;
    }
}

Voir http: // msdn. microsoft.com/en-us/library/system.windows.forms.keypresseventargs.handled.aspx pour plus d'informations.

Autres conseils

Voulez-vous dire que vous voulez ignorer la touche Entrée?

Vous pouvez ajouter un événement keydown et ignorer la touche Entrée ici ...

private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            e.SuppressKeyPress = true;
        }
    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top