I\'m looking to accept digits and the decimal point, but no sign.
I\'ve looked at samples using the NumericUpDown control for Windows Forms, and this sample of a Num
This is the only code needed:
void MyTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);
}
This only allows numbers to be inputted into the text box.
To allow a decimal point or minus sign, you can change the regular expression to [^0-9.-]+
.