Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to prevent Non-Numeric Input in DataGridView ?
Message
 
 
À
16/10/2007 23:40:58
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
01261399
Message ID:
01279272
Vues:
8
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform