Windows Forms: Textbox that only accepts integer values

1152400 pts.
Tags:
.NET
Windows Forms
In Windows Forms, I have a textbox that I only want to accept integer values. Usually what I do is overload the KeyPress event and remove all the other characters. Is there a better way to do this? Thank you very much.
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    You could try converting the input and testing it. Wrap it in a TRY/CATCH. If you still have issues, post your code and we will take a look.
    135,305 pointsBadges:
    report
  • TheRealRaven
    It might work best to use a NumericTextBox class. You might modify the Microsoft example to leave out the decimal point if you really want only integers.
    36,370 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: