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
Simpler answer:
_textBox.TextChanged += delegate(System.Object o, System.EventArgs e) { TextBox _tbox = o as TextBox; _tbox.Text = new string(_tbox.Text.Where(c => (char.IsDigit(c)) || (c == '.')).ToArray()); };