Change initial form displayed. From form1 to form2

G

garyusenet

I have a windows form project which originally contained one form, the
standard form. Form1.

I've added another form now, form2 which i'm experimenting with.

I'd like to display form2 when i run the application instead of form1.

How do i do this?

I know this must be a frequent request, but i've searched and can't
find a straightforward explanation (which i'm sure must exit!)

Thankyou,

Gary-
 
M

Marc Gravell

Look for a static Main method; in 1.1 I believe this used to go into
Form1.cs when auto-generated; in 2.0 it tends to live in Program.cs.
In an auto-generated method it basically just does an Application.Run
on a new instance of Form1; so change it to your desired form. Note
that the project properties can be used to disambiguate if there are
multiple eligible Main methods that look like an entry-point.

Marc
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

And the answer is even simplier, look for your Main method and change this
line from:

Application.Run(new Form1());

To:

Application.Run(new Form2());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top