[.NET][C#] Touche clavier
Bonjour,
J'aurais voulu savoir si l'utilisateur à pressé la touche "enter"
Code:
1 2 3 4 5
|
private void txtPassword_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
} |
Mais la e.KeyChar me renvoi un truc illisible dans le cas de "Enter" ou "Return".
Merci d'avance
fab2050
Re: [.NET][C#] Touche clavier
Citation:
Envoyé par fab2050
Bonjour,
J'aurais voulu savoir si l'utilisateur à pressé la touche "enter"
Code:
private void txtPassword_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){}
Mais la e.KeyChar me renvoi un truc illisible dans le cas de "Enter" ou "Return". Merci d'avance
fab2050
Petit conseil
Prend le temps de consulter la doc MSDN ton souci n'était vraiment pas difficile à résoudre
Notamment en creusant le terme Clé KeyPressEventArgs , tu aurais fini par tomber sur ceci
:arrow: Énumération Keys
Et donc sur : Keys.Enter
Ce qui donne
Code:
1 2 3 4 5 6 7
| private void txtPassword_KeyPress(object sender, KeyEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
//... ;
}
} |