【WinForm】TextBox只能输入中文,英文,数字,不允许输入特殊字符

    xiaoxiao2022-07-05  181

     

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { Regex rg = new Regex("^[\u4e00-\u9fa5a-zA-Z0-9\b]$"); if (!rg.IsMatch(e.KeyChar.ToString())) { e.Handled = true; } }

     

    最新回复(0)