Hi,
could you please help me with this one: How do I make a textbox numeric? And also, how do I format the text length? I.e. I want the user to input numbers with maximum 2 digits only.
Printable View
Hi,
could you please help me with this one: How do I make a textbox numeric? And also, how do I format the text length? I.e. I want the user to input numbers with maximum 2 digits only.
Using a NumericUpDown box instead is probably easier. You can set the max/min, number of d.p.s and it only accepts numbers :)
Thanks, very good! I was not aware of this control.
While we're at it, do you know if it is possible to make a textbox numeric?
This question has been asked and answered numerous times, so a forum search should give you plenty of information. The best implementation of a numeric TextBox I've seen is the NumberBox in the WFC library in my signature. It's pretty easy to handle KeyPress events to handle the majority of situations but, as always, the devil is in the detail. It becomes tricky to handle the less common sets of circumstances, but you've still got to account fopr those circumstances because if there's a way to break your app then users will find it.
Nice! I downloaded NumberBox and it is working fine!
Thanks a lot!