shiny
shiny

Reputation: 33

having problem with closing a form that has input

I want to close all forms but this code doesnt work. Could someone give me the right code?

private Form0 _form0 = null;
public Form1(Form0 form0)
{
   InitializeComponent();
   form0.Hide();
   _form0 = form0;
}

form0 show a demo when user press the entrance button form1 will be shown.

private void ToolStripMenuItem7_Click(object sender, EventArgs e)
{
   Form1 form1 = new Form1(form0);
   form1.Dispose();
   form1.Close(); 
}

Upvotes: 0

Views: 85

Answers (2)

user586399
user586399

Reputation:

Application.Exit(); will close all forms and entire application as well.

Upvotes: 0

SwDevMan81
SwDevMan81

Reputation: 49978

private void ToolStripMenuItem7_Click(object sender, EventArgs e)
{
    using(Form1 form1 = new Form1(form0))
    {
       form1.Show();
    }
}

Upvotes: 1

Related Questions