?
Solved

How do I start two forms at the same time?

Posted on 2009-04-17
5
Medium Priority
?
205 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:Mickeys
  • 2
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
CuteBug earned 2000 total points
ID: 24165937
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
 

Author Comment

by:Mickeys
ID: 24165954
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
 
LVL 11

Expert Comment

by:bmatumbura
ID: 24165957
Start the second form from the first form's Load event handler
0
 

Author Comment

by:Mickeys
ID: 24165977
I manged it. I moved it into NyBok and started it there. I guess that was what nr 1 was.
:-)
Thx
0
 
LVL 16

Expert Comment

by:CuteBug
ID: 24165993

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question