C#教程:KeyPress事件使用实例|方法

KeyPress事件的使用
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
this.Text = e.KeyChar.ToString();
e.Handled = True;
}
}