C# 只能输入数字或特定字符

private void txtmoney_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == 46 || e.KeyChar == 8)
            {
                return;
            }
            else
            {
                e.KeyChar = (char)Keys.None;
                return;
            }
        }
原文地址:https://www.cnblogs.com/baishahe/p/1127807.html