private void validate_EnsureNumber(object sender, CancelEventArgs e)
{
int outValue;
TextBox text = (TextBox)sender;
if (!int.TryParse(text.Text, out outValue)) {
MessageBox.Show(this, "Invalid number: " + text.Text, "Invalid number", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
e.Cancel = true;
}
}