📜  windows 文本框唯一字符 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:43.641000             🧑  作者: Mango

代码示例1
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    var regex = new Regex(@"[^a-zA-Z0-9\s]");
    if (regex.IsMatch(e.KeyChar.ToString()))
    {
        e.Handled = true;
    }
}