Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to prevent Non-Numeric Input in DataGridView ?
Message
 
 
To
16/10/2007 23:40:58
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
01261399
Message ID:
01279272
Views:
9
>Try something like (if you want to force numeric instead, change to ! to force numeric or use char.IsNumeric):
>
>public class NumbersOnlyTextBox : TextBox
>{
>  public NumbersOnlyTextBox()
>  {
>    KeyPress += new KeyPressEventHandler( HandleKeyPress );
>  }
>
>  private void HandleKeyPress( object sender, KeyPressEventArgs e )
>  {
>    if ( ( char.IsDigit( e.KeyChar ) || char.IsControl( e.KeyChar ) ) )
>      e.Handled = true;
>  }
>}
>
>

Hi Tracy,

Did you create this class visually? How do you create textboxes based on this class?

Also would it be possible to have something like this for money entry?

Thanks in advance.

I create this class in App_Code directory as cs file, am I correct? If yes, how now can I use this class? How can I put it on the toolbox?

Also, I've just realized, that this class probably can not be used in ASP.NET, correct?

Thanks again.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform