Close one form after new one opens

Posted on 2009-04-20
Last Modified: 2012-05-06

I am using c# with windows Forms.

I have a form that accepts some information, then opens a second form. After the second form is open I want to close the first form. How do I do that?
Question by:charlesbaldo
    LVL 39

    Accepted Solution

    You mean that you want to wait on the form_load until the form is fully loaded? The easy thing to do is to do something like this (not tested for typos):

    // in parent
    Form newForm = new MyForm();
    newForm.parentForm = this;
    newForm.Show();                  // do not use "this" because then closing parent will close child
    // in child
    public Form parentForm
         set (Form value)
                _parentForm = value;
    // in child in form_load

    Open in new window


    Author Closing Comment

    Havn't coded yet or check for typos :) but I get the idea thanks

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now