Override TextBox class like following :
class TextBoxNum:TextBox {
private String _Text="";
private Regex regex=new Regex("^[0-9]*$",RegexOptions.Compiled);
protected override void OnTextChanged(EventArgs e) {
if (Text==_Text) return ;//Don't recurs
if (regex.Match(Text).Success) _Text=Text;
else {
int pos=SelectionStart+_Text.Length-Text.Length;
Text=_Text;
SelectionStart=pos<0?0:pos;
}
}
}
}
And declare in your code textBoxOrderid as a TextBoxNum :
TextBoxNum textBoxOrderid
Hope it helps,
Ludovic SOEUR.
"Jo Segers" <jo*******@alro.be> a écrit dans le message de
news:Ot**************@tk2msftngp13.phx.gbl...
Hi,
How can I restrict the keyboard input in a textBox to 0..9? In the
keydown event KeyValue is get only. Where can I alter the keyboard input?
Mvg,