|
-
March 20th, 2003, 01:52 AM
#1
Accepting numbers in textboxes?
Hi all. I would like to know if it's possible to accept numbers only in textboxes? In VC++ it's possible. But i can't seem to find in the properties that accept only numbers in the properties window.
If it's not possible, then i would like to know how do i validate in the textboxes that the entered data are right format. If i were to check the textboxes by converting it to number using Int32.Parse method after a button has been clicked, it will throw an exception of invalid format. I would like to know how do i check the textboxes without throwinng an exception. Thanks
-
March 20th, 2003, 04:04 AM
#2
It is rather odd they don't have an option to do this considering how common it is to want this. Atleast I haven't found one.
Anyway, what I've done so far is add an event handler for key down. If the key isn't an allowable character then I'll change the text.
-
March 21st, 2003, 01:31 PM
#3
you can make a control having keypress event which only accepts digits and throws rest out
methodName...(KeyPressEventArgs e)
{
if(Char.IsDigit(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == 8)
{
/// blah blah blah
}
}
Paresh
- Software Architect
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|