There must be a better way than a constrained numeric updown control.
A:
The MaskedTextBox might be of use. Failing that, I recommend using an ordinary TextBox with an OnTextChange event handler that checks to make sure the value entered is actually a number. Any non-numerical characters, and you can bang out a message box, or simply remove those characters completely, depending on your needs.
The NumericUpDown controls are slow to use sometimes, but they have intrinsic data validation which in some cases is quite useful. If the control is one the user is not going to use often, consider using it. Otherwise the MaskedTextBox or TextBox is the way to go.
Charlie Salts
2009-08-24 20:35:10
The MaskedTextBox does not exist on the Mobile platform.
Henk Holterman
2009-08-24 21:19:01
I suspected as much, hence why I added 'failing that.. '.
Charlie Salts
2009-08-24 22:18:41
@moster67: it's my favorite hack of all time. This is a problem that vexed me horribly for years until I found this code.
MusiGenesis
2009-08-25 14:00:18
Not useful for my current needs, but that is a really cool and inventive solution! If I could up-vote more than once, that would get a couple. :)
eidylon
2010-05-12 15:19:32