To allow only numeric value in textbox, the KeyPress event of the text box can be handled to achive it. You will just need to add the following code.
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar) & (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar) & (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
}
}
No comments:
Post a Comment