How to open another form when clicking on a button and close the first form at the same time? RRS feed

  • Question

  • Hello! I am trying to have a button, like a startup screen. So, when you press the button it shows a new form and closes the first one. How, would i do that?
    Thursday, August 30, 2018 10:20 PM

All replies

  • The following appears to meet your needs. Note when the child form closes the main form which has hidden will close and in return close the application.

    private void OnButton1Click(object sender, EventArgs e)
        var form2 = new Form2();
        form2.Closed += (s, args) => this.Close(); 

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, August 30, 2018 10:29 PM
  • Thanks! :)
    Thursday, August 30, 2018 11:12 PM
  • Hi AustinTh3Gr3at,

    If your question has been solved, please mark the useful reply as answer to close the thread. This will make answer searching easier in the forum and be beneficial to community members.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 3, 2018 5:46 AM