I am stuck into a problem and need inputs. Here is the description -
I have a txtPenaltyDays in windows form C#
private void txtPenaltyDays_TextChanged(object sender, EventArgs e)
{
if(Convert.ToInt16(txtPenaltyDays.Text) > 5)
{
MessageBox.Show("The maximum amount in text box cant be more than 5");
txtPenaltyDays.Text = 0;// Re- triggers the TextChanged
}
}
But I am running into problem because this fires 2 times. Because of setting the text value to 0. My requirement is that it should fire only one time and set the value to 0.
Any suggestion is deeply appreciated.