控制textbook输入字符

在KeyPress事件中假如如下代码此实例表示可输入数字退格和“.”。

具体字符KeyChar见连接 http://www.cnblogs.com/linji/archive/2012/10/24/2737407.html

private void txtCOLD_PRECIPITATION_KeyPress(object sender, KeyPressEventArgs e)
        {

            if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && (e.KeyChar != 46))
            {
                
                e.Handled = true;
            }
        }

原文地址:https://www.cnblogs.com/wuhailong/p/3909410.html