вместо того, чтобы показывать форму 0-9999 раз, вы можете передать значение (0-9999) в форму и очистить поля в этой форме 0-9999 раз после того, как пользователь нажмет на сохранение, а затем закрыть его. 1001 *
например:
//on main form:
int i = 0;
//parse the textbox1.text to int and check the result:
if(!int.TryParse(textbox1.Text,out i)||i<0||i>9999)
{
//incorrect int value
MessageBox.Show("Please enter a valid value");
}
else //correct int value
{
subform mysub=new subform(i);
subform.ShowDialog();
}
//on your subform:
int timebeforeclose=0;
public subform(int count)
{
timebeforeclose=count;
}
private void btnSave_Click(object sender, EventArgs e)
{
//1.save your data or whatever...
//2.empty any fields you want..
//update timebeforeclose:
timebeforeclose--;
//check the timebeforeclose:
if(timebeforeclose==0)
{
this.Close(); //close this form when reaches the specified number.
}
}