First of all, this is not a good question: 1) there is no such thing as "open a form", even though you can "close" a form; 2)
you show the form, so it should be obvious that it's up to you to decide what to open and what's not; you cannot ask questions every time you have to decide on something as trivial as that; if you asked how to do it nicely, it would be a different story.
So, in development of second item above, you can use
lazy initialization pattern, or,
load on call, which is probably the best in such cases:
http://en.wikipedia.org/wiki/Lazy_initialization#C.23[
^].
In a very simple form, you should just encapsulate the method of showing the form:
class SomeForm : Form {
void ShowOneMoreForm() {
if (oneMoreForm == null) {
oneMoreForm = new OneMoreForm.Create();
oneMoreForm.Owner = this;
}
oneMoreForm.Show();
}
OneMoreForm oneMoreForm;
}
Simple, isn't it?
This guarantees that you have only one form of this type, and that it preserve its state (because you never created it second time). Sometimes, this approach solve much more complex problem: some operations in the implementation of
ShowOneMoreForm
cannot be performed to early, for example, in its constructor, or when the main form is not properly setup. Sometimes it is hard to find out appropriate moment for this. And in this load-on-call solution, you only create and setup this form when it is really required for the very first time, say, when the user needs to work with it.
—SA