How do I start two forms at the same time?

Hi,
I have a windowsApplicatoin.
I want to start to forms at the same time.
I am able to start one but how do I start the second one?

The one that doesnt start is:
Application.Run(new Bokvisare());  


static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);          
            Controller controller = new Controller(bibliotek, visare);               
            Application.Run(new NyBok(controller));
            Application.Run(new Bokvisare());   		
        }

Open in new window

MickeysAsked:
Who is Participating?
 
CuteBugCommented:
You cannot start two forms this way...

There are two other ways:
1. Once the first form NyBok is created, create a new instance of Bokvisare and call its Show method.
2. Split each form into two different applications and from the first application invoke the second application.

http://www.csharp-station.com/HowTo/ProcessStart.aspx
0
 
MickeysAuthor Commented:
Number 1:

Like this?

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Bokvisare visare = new Bokvisare();
            Controller controller = new Controller(bibliotek, visare);              
            Application.Run(new NyBok(controller));
            visare.Show();
}
0
 
bmatumburaCommented:
Start the second form from the first form's Load event handler
0
 
MickeysAuthor Commented:
I manged it. I moved it into NyBok and started it there. I guess that was what nr 1 was.
:-)
Thx
0
 
CuteBugCommented:

Since you are passing the instance of Bokvisare to Controller, you can call the Show method of Bokvisare instance after the Controller has properly initialized.
0
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.