I have a windows forms app with a textbox control that I want to only accept integer values. In the past I\'ve done this kind of validation by overloading the KeyPress event
simply use this code in textbox :
private void textBox1_TextChanged(object sender, EventArgs e) { double parsedValue; if (!double.TryParse(textBox1.Text, out parsedValue)) { textBox1.Text = ""; } }