我遇到了一个问题,需要你的帮助。以下是问题描述:
我在Windows Form C#中有一个txtPenaltyDays
。
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
}
}
但是我遇到了问题,因为这个函数会触发两次。这是因为将文本值设置为0。 我的要求是它只应该触发一次并将值设置为0。
非常感谢任何建议。