Is that code is working on DataGridView Control ? I've been tried to use that code in DataGridView but no luck ...
Thanks :-)
>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 all,
>>
>>I want to prevent non-numeric input from the first user's keystroke in DataGridView (mimic behaviour of Numeric TextBox in VFP).
>>
>>Anybody know how to do it ?
>>
>>Thanks in advance :-D
Handi Rusli
"Treat people with respect and courtesy, and one will be blessed. Complete task heartily, with best effort and responsibility, and one can achieve the greatest."