How to keep the form instance for further re-open?
I am using C# 2010. From my MdiParent toolstrip I am using the following codes to open the mdichild.
public partial class Form1 : Form
{
Form3 MyNewName = New Form3();
private void toolStripButton2_Click(object sender, EventArgs e)
{
//Form3 MyNewName = New Form3();
MyNewName.MdiParent = this;
MyNewName.FormBorderStyle = FormBorderStyle.No开发者_运维问答ne;
MyNewName.Dock = DockStyle.Fill;
MyNewName.Show();
}
}
And for once the close button is clicked all of mdichildren use to close by its MDI_form closing event. But the problem is I cannot reopen the form it says "cannot access a disposed object". And if I use
Form3 MyNewName = New Form3();
then the other subs are not running...
So how to keep the instances permanently even if the form is closed?
Use Form.Hide
instead of Form.Close
.
精彩评论