I am fairly new to Winforms, and I would like to know how to use a MaskedTextBox to ensure that only numerical values(decimals included) are entered by the user.
I have tried the masked feature using “/^[-+]?[0-9]+(.[0-9]+)?$/” and was not successful with that. What I want, even if with an ordinary textbox, is to allow only numerals/decimal values
I adapted this NumericTextBox control: http://sanity-free.org/forum/viewtopic.php?pid=1205#p1205
If you want it apart of your toolbox, you’d probably create a new control based on a TextBox and paste the code in that link into the code section.
Here’s my version of it. I don’t know how much I’ve modified it as I’ve had it a long time.
NumericTextBox.Designer.cs:
NumericTextBox.cs