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?
答案 0 :(得分:1)
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]+");