private void textBox2_KeyPress(object sender, KeyPressEventArgs e){ if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar)) { this.Text = e.KeyChar.ToString(); e.Handled = true; }}