Close one form after new one opens


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?
Charles BaldoSoftware DeveloperAsked:
Who is Participating?
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

Charles BaldoSoftware DeveloperAuthor Commented:
Havn't coded yet or check for typos :) but I get the idea thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.