CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Closing Form

  1. #1
    Join Date
    Jul 2006
    Posts
    45

    Smile Closing Form

    Can anyone help me out from closing one form from another form, may be Form1 was my first form and i have added Form2 to that application as new item, now i want that when anyone clicks on the "Show Form2" button, Form2 should be showed and Form1 should get closed. Please help me out soon.

  2. #2
    Join Date
    Mar 2006
    Location
    Craiova, Romania
    Posts
    439

    Re: Closing Form

    From first form:
    Code:
            private void button1_Click_1(object sender, EventArgs e)
            {
                Form2 frm = new Form2();
                this.Visible=false;
                frm.Show();
            }
    From second form:
    Code:
    private void Form2_FormClosed(object sender, FormClosedEventArgs e)
    {
    Application.Exit();
    }
    Bogdan

    If someone helped you then please Rate his post and mark the thread as Resolved
    Please improve your messages appearance by using tags [ code] Place your code here [ /code]

  3. #3
    Join Date
    Jan 2007
    Posts
    102

    Re: Closing Form

    How about closing the main application and before closing you want to do some processing. For example, before closing all created files must be deleted.
    In C++ you can do that in the constructor of the main class, but how is that is Visual C#?

  4. #4
    Join Date
    Jan 2007
    Posts
    102

    Re: Closing Form

    Ok, I got it:

    private void MainMap_FormClosed(object sender, FormClosedEventArgs e)
    {
    }

    Create eventhandler in MainForm.designer by dubbleclicking in the propperty item. and do some terminating processes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured