GrayFullBuster
GrayFullBuster

Reputation: 1063

How can I open a form after a specific form closes? the form is from another project in C#?

I got 2 projects in a solution, my main project is project 1 and during in projects 1 main form load event I run a form from project 2, My problem is how can I show a form from project 1 after the form from project 2 closes?

//Here is the form from project 2 will run on project 1 mains form load
    pp2.FormLoader frmLdr = new pp2.FormLoader();
                frmLdr.MdiParent = this;
                frmLdr.Show();

//the form from project 2 will automatically closes after a couple of seconds, after that this form should be automatically show. How can I possibly do this? Thanks!

                FormProcess frmSvrProc = new FormProcess();
                frmSvrProc.MdiParent = this;
                frmSvrProc.Show();

Upvotes: 1

Views: 150

Answers (1)

Steve
Steve

Reputation: 216293

Now I understand your question (well apart from the fact that you should really rename that form)

You could subscribe to the Form_Closed event of frmLdr

 pp2.Loader frmLdr = new pp2.Loader();
 frmLdr.MdiParent = this;
 frmLdr.FormClosed += new FormClosedEventHandler(frmLdrClosed);
 frmLdr.Show();
 ....

and move the code that opens the second form inside the event handler

 private void frmLdrClosed(object sender, System.EventArgs e)
 {
       FormProcess frmSvrProc = new FormProcess();
       frmSvrProc.MdiParent = this;
       frmSvrProc.Show();
 }

Upvotes: 2

Related Questions