protected override void OnKeyPress(KeyPressEventArgs e)
{
//base.OnKeyPress(e);
//如果是退格键
if (e.KeyChar == (char)Keys.Back)
{
return;
}
//e.Handled = true;//不接受输入
double outDb=0;
if (double.TryParse(this.Text + e.KeyChar.ToString(), out outDb))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
只能输入数字的TextBox自定义控件
最新推荐文章于 2021-05-10 10:49:59 发布