控制winform中控件的输入格式

 private void txtNum1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '
' && e.KeyChar != '')
            {
                e.Handled = true;
            }
        }
原文地址:https://www.cnblogs.com/xuekai-to-sharp/p/3554628.html