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; } }