How to Only allow numbers and a Minus "-" in a Textbox
Just add the -
to your regex character group, in a position that's not making a range of characters:
private void txtDicountSettlement_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
Regex regex = new Regex("[^0-9-]+");
e.Handled = regex.IsMatch(e.Text);
}
I think you want something like this
^[0-9-]*$
It will match any digit any time and n no of dashes and will ignore any other character
[^-]+[^0-9]+
should prevent any input that's not an integer or a negative integer.