I am having trouble making a Windows Form Application. I want to proceed to a second form while closing the first (Going from Main menu to Level 1) but I cant seem to figure out why after the 2nd form loads, both forms close out.

Here is the code I have on the Main Menu Form

private void btnContinue_Click( object sender, EventArgs e )
        {
            Level1 Frm = new Level1 ( );
            Frm.Show ( );
            this.Close ( );

        }

Note, Even after I tried

Frm.ShowDialog();

instead of Frm.Show, the result was not what I wanted.

Thank you in advance for the responses

Recommended Answers

All 4 Replies

IF you close the first it will close your project.
Hide your first form instead of close

this.hide();

IF you close the first it will close your project.
Hide your first form instead of close

this.hide();

Thanks works like a charm... what about the resources it is using since this application will have about 10 levels... How can I go back and release the resources that form is using?... or will it really matter that much?

I don't know what type of resources are you using and it matter or not.
But one thing i would like to tell you is that, you can able to close your all form accept your startup form
for example you have 4 form
form1 startup form then you have to open form until ur project is running its does't matter other you close or not.

So my advice for you is that try to avoid much resource on startup form

form1 f1=new form1;
f1.Show();
this.Close();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.