Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! all i have created two Windows Forms Form1 and Form2, but it want to run form2 as my default starting form how can i do that?
Posted

When you create a C# project by default Program.cs file will create.
In this file you can see this code.
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());

If you want to change the start up form from Form1 to Form2 then just change the third line.
Application.Run(new Form2());
 
Share this answer
 
v2
Comments
Toniyo Jackson 14-Apr-11 6:35am    
Why down voted? Any thing wrong?
Dylan Morley 14-Apr-11 6:37am    
Have my 5, looks correct to me!
Toniyo Jackson 14-Apr-11 6:40am    
Thanks Morley
Nischal Bhatt 14-Apr-11 6:43am    
Worked like a charm for me.. :)
Toniyo Jackson 14-Apr-11 6:44am    
If it works vote and accept the answer :)
Have a read of this

Change Startup form[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900