deanlee17
asked on
Textbox check
Hi guys,
I would like to check that a textbox contains no characters and can only be (for example)...
1
1.00
100,000.00
etc
Thanks,
Dean.
I would like to check that a textbox contains no characters and can only be (for example)...
1
1.00
100,000.00
etc
Thanks,
Dean.
check http://emoreau.com/Entries/Articles/2003/03/Creating-your-own-Windows-Custom-Control.aspx
ASKER
I shud maybe mention, this is a WPF application.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One solution would be to capture the onKeyUp event. When a user enters a character in the textbox you can use this event to ensure he has only entered a valid character (in this case numeric only)
Hi.
1. On the KeyPress event, set e.handle to true if the character is not a digit, dot (.) or backspace.
2. on validate event you have several options:
a. perform a Double.TryParse on the textbox's content and set e.cancel to true if it fails.
you can check for range validity as well.
b. Use regular expression to check it.
Good luck.
1. On the KeyPress event, set e.handle to true if the character is not a digit, dot (.) or backspace.
2. on validate event you have several options:
a. perform a Double.TryParse on the textbox's content and set e.cancel to true if it fails.
you can check for range validity as well.
b. Use regular expression to check it.
Good luck.