private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
//e.KeyChar != 8 > Backspace
//e.KeyChar != 46> .
if (!Char.IsDigit(e.KeyChar) && (e.KeyChar != (char)Keys.Enter) && (e.KeyChar != 46) && (e.KeyChar != 8))
{
MessageBox.Show("กรุณาป้อนแต่ตัวเลขครับ...", "Error");
e.Handled = true;
}
}
No comments:
Post a Comment