**Hello, I'm trying to clean a TextBox
by pressing the ctrl+delete keys but I don't get the option KeyCode
, does anyone know what I'm doing wrong?
private void txtUsuario_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyCode == Keys.Delete && e.Control)
{
txtUsuario.Text = "";
}
}
UPDATE:
I got what I was looking for as follows:
private void txtUsuario_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Back && e.Control)
{
txtUsuario.Text = "";
}
}
But, this form adds a strange character:
How is it solved?
You have to put two conditions (pressed delete and pressed Control) to evaluate the KeyPress