• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 750
  • Last Modified:

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 Baldo
Charles Baldo
1 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

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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now