如下代码即可.在textbox的keypress里边加入如下代码: private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsDigit(e.KeyChar)) { e.Handled = true; } } 转载于:https://www.cnblogs.com/CShapWinForms/archive/2006/05/10/396302.html