对文本框限制只能输入数字

private void txtAge_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        
{
            
if ((e.KeyChar < 48 || e.KeyChar > 57 )&& e.KeyChar != 8 && e.KeyChar !=46)
                e.Handled 
= true// Remove the character
        }
posted @ 2004-08-31 20:14  怀沙  阅读(2595)  评论(7编辑  收藏  举报