How to show form after it was closed?
I hav开发者_StackOverflowe a MDI application with couple of windows. Is there any way to disable disposing form after it was closed by the user. I want to be able to reopen that form just by calling form.Show()
method.
You could use Form.FormClosing Event.
The FormClosing event occurs as the form is being closed. When a form is closed, it is disposed, releasing all resources associated with the form.
If you cancel this event, the form remains opened. To cancel the closure of a form, set the Cancel property of the FormClosingEventArgs passed to your event handler to true.
This should do the same thing as you'd do with Form.Show()
You can save the values of the Form into a separate class before you call the Close() method of the form and load a new form which takes it's values from the saved class.
send the main form as a parameter to the child form, then the child form can reference the main form t any time
public Form MainForm = null;
public Sample(ref Form mainForm)
{
InitializeComponent();
MainForm = mainForm;
}
private void Sample_FormClosed(object sender, FormClosedEventArgs e)
{
MainForm.Show();
}
精彩评论