Monday, January 4, 2010

Validation for textbox : C# window application

private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= 47 && e.KeyChar <= 58) || (e.KeyChar == 46) || (e.KeyChar == 8))
{
e.Handled = false;
}
else
{
e.Handled = true;
MessageBox.Show("Please enter only number");
}
}

No comments: