控制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;
            }
        }

posted @ 2014-08-13 10:29  喜爱糖葫芦  阅读(245)  评论(0编辑  收藏  举报