u have 2 steps.
1_ First u should check ur pressed Key, so do it as
Code:
textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
Then in ur textBox1_KeyPress put following codes;
Code:
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if( (e.KeyChar > 57 | e.KeyChar < 48) )
e.Handled = true;
}
2_ for makeing limit for lenght of ur textbox set
MaxLength to
2
HTH
Always:),
Hovik Melkomian.