I wish to validate this TextBox against negative values and characters (must be integer without decimal)
It works well for . but I am not able to understand why it accepts negative value and characters?
My code is :
private void txtLifeMonths_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && (e.KeyChar == '.') && (e.KeyChar >= 0) && (e.KeyChar != (char)Keys.Back))
e.Handled = true;
}