控制winform中控件的输入格式

 private void txtNum1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(e.KeyChar <= '9' && e.KeyChar >= '0') && e.KeyChar != '\r' && e.KeyChar != '\b')
            {
                e.Handled = true;
            }
        }

 

posted @ 2014-02-18 17:29  蚂蚁拉车  阅读(211)  评论(0编辑  收藏  举报