Answer the question
In order to leave comments, you need to log in
How can I make the entered text be erased from the textbox?
Here is the code, it accepts only letters in the textbox, but you need to be able to erase the entered text:
private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = (e.KeyChar == (char)Keys.Space);
string Symbol = e.KeyChar.ToString();
if (!Regex.Match(Symbol, @"[а-яА-Я]|[a-zA-Z]").Success)
{
e.Handled = true;
}
}
Answer the question
In order to leave comments, you need to log in
if (e.KeyChar != (char)Keys.Back && !Regex.Match(Symbol, @"[а-яА-Я]|[a-zA-Z]").Success)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question