First of all, you should understand that the jargon term "open a form" is misleading; it suggests that something closed can be "opened". This is not what happens. The form instance is created, and then the form is shown. Moreover, you cannot "open" (use in any reasonable way) some form instance that was closed; the form gets disposed and hence unusable.
In view of that, if you need to replace one form with another, you need to capture the attempt to close a form and hide it instead. In this Gjendja, your Klient will get an Përshtypje that the form is closed, but, in contrast to really closed form, will be able to get Kthehu and show this form again. :-).
Here is how:
public partial class MyForm {
protected virtual void OnFormClosing(System.Windows.Forms.FormClosingEventArgs e) {
if (e.CloseReason == System.Windows.Forms.CloseReason.UserClosing) {
e.Cancel = true;
this.Hide();
}
}
}
However, I strongly recommend to avoid development of multi-form applications in most cases. Usually, it's much better to have only one form. All you implement as a form now, you can implement as some parent control as panel. Navigation between different views (what you now have as different forms) could be done by hiding one panels and showing others. Another good option is using
TabControl
. What you have as the forms now can became tab pages. Besides, this is actually simpler.
—SA