How can I make a textbox in which can be only typed a number like 12.00 or 1231231.00 or 123123
I’ve done this in a very long way and I’m looking for the best and fastest way.
Also the decimal separator must be culture specific.:
Application.CurrentCulture.NumberFormat.NumberDecimalSeparator
That’s a fairly straightforward operation. You’ll need to filter the keys that you don’t want out and then perform some additional checks.
Add the following code to the KeyDown event of the textbox:
And then, since a user may paste values into the textbox, you add the following to the TextBox’s Validate event
I wrote a class to handle a variety of filters for you [which obviously includes the culture-specific decimal symbol].
Add this class to your project
and then use it in your form as follows