C#中TextBox只能输入数字的代码
private void txbSleep_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b'))
{
e.Handled = true;
}
}
private void txbSleep_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b'))
{
e.Handled = true;
}
}