private void txtPrice_KeyPress(object sender, KeyPressEventArgs e) { if (!((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == '.' || e.KeyChar == '')) { e.Handled = true; } else { if (e.KeyChar == '.') { string str = txtPrice.Text; int num = str.IndexOf('.'); if (num != -1) { e.Handled = true; } } } } 相关文章: