Reputation:
I have a code
private void DataGridTypePayments_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);
}
I need input number or backspace.How i can disable input symbol space?
Upvotes: 1
Views: 9423
Reputation: 16564
The C-style escape for the backspace character is \b
which is also the Regex escape for a word boundary. Fortunately you can put it in a character class to change the meaning:
e.Handled = Regex.IsMatch(e.Text, "[0-9\b]+");
Upvotes: 1