1

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();
GrayFullBuster
  • 1,033
  • 3
  • 18
  • 23
  • Where on earth do you have found the property MdiParent on a instance of a Process class? (Not to mention the Show() method) Do you mean `Form frmShowProc` – Steve Dec 20 '12 at 00:32
  • process is the name of the form :D – GrayFullBuster Dec 20 '12 at 00:34
  • I am speechless.... I'm asking my mind to find something reasonable to say – Steve Dec 20 '12 at 00:35
  • 1
    There is already a class in .NET called Process, so it is a little confusing to name your form Process. Might name it something like ProcessImage, ProcessAccounts, ProcessRabbits, or FlyingProcess, DrivingProcess, whatever it is that it processes or is a process of. – AaronLS Dec 20 '12 at 00:38
  • [Process](http://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.100).aspx) is the name of a well know class that handles running of other Processes in your machine. Your choice of name for that form is really confusing. – Steve Dec 20 '12 at 00:39
  • sorry i just edit it when i paste it :( – GrayFullBuster Dec 20 '12 at 00:40
  • updated. ... sorry for the confusion – GrayFullBuster Dec 20 '12 at 00:41
  • There are lots of examples of this already at this link. Note they each will give you a slightly different behavior depending on what exactly you want to do. Also Modal windows will change this significantly, because showing a modal will not run any statements after ShowModal until the modal is closed. This may or may not be useful depending on the details of your goal: http://stackoverflow.com/questions/3965043/how-to-open-a-new-form-from-another-form – AaronLS Dec 20 '12 at 00:42
  • To adapt these examples to your needs, you would wire up to the Closed event of the first form. – AaronLS Dec 20 '12 at 00:44

1 Answers1

2

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();
 }
Steve
  • 213,761
  • 22
  • 232
  • 286