G
Guest
Hi, this is a simple question.
i want to click a button to show a form. If I use this code:
button_click()
{
MyNewForm myNewForm = new MyNewForm;
myNewForm.Show();
}
every time I click the button I get multiple instances of the form.
Understandably.
If I move the instantiation of the MyNewForm object out of the method so
that its a class scope field:
MyNewForm mynewform = new MyNewForm;
button_click()
{
myNewForm.Show();
}
This solves the multiple click problem, as it just keeps "showing" the form
object, but if I close the form and hence destroy the instance of the form, I
can no longer show the file and an error is raised as the form no longer
exists. Understandably.
This must be a common procedure. How does everyone do this??
Many thanks for your answers to this.
Ant
i want to click a button to show a form. If I use this code:
button_click()
{
MyNewForm myNewForm = new MyNewForm;
myNewForm.Show();
}
every time I click the button I get multiple instances of the form.
Understandably.
If I move the instantiation of the MyNewForm object out of the method so
that its a class scope field:
MyNewForm mynewform = new MyNewForm;
button_click()
{
myNewForm.Show();
}
This solves the multiple click problem, as it just keeps "showing" the form
object, but if I close the form and hence destroy the instance of the form, I
can no longer show the file and an error is raised as the form no longer
exists. Understandably.
This must be a common procedure. How does everyone do this??
Many thanks for your answers to this.
Ant