Masked TextBox with decimal numbers

Sagar Upadhyay picture Sagar Upadhyay · Jan 21, 2013 · Viewed 15.6k times · Source

In my window application I need masked textbox which accept real decmal numbers.

eg.
1) 1.56
2) 22.34
3) 123.34
4) 12312.34
This all value should be valid.

Can anyone tell me how can I do this?
And ya if anyone have better solution for real decimal numbers, instead of this masked TextBox than I love to see it.
Thanks...

Answer

Dai picture Dai · Jan 21, 2013

Instead of using a MaskedTextbox, consider using NumericUpDown instead. It supports System.Decimal numbers which supports most real-set numbers you should be caring about.

The NumericUpDown.DecimalPlaces property supports up to 99 decimal places.