Click here to Skip to main content
15,919,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

i've two forms(Form1 & Form2). i want to run just form2 only.please reply
Posted

1 solution

Hi ravi,

A Form is run when it's called from Program.cs (if using C#, if you mean the startup form)

C#
[STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form2());
        }


You can right click on the Project->Property->Startup form->Form2 (both C# & VB can use this way)

Regards
 
Share this answer
 
v2
Comments
ks ravi 19-Jan-11 23:24pm    
hi Jerrykid,

i'm bit confused that every time do i change 'Application.Run(new Form2());'//form2() as Form1() OR Any Alternatives because i've Application.Run(new Form1());code already there.
thatraja 19-Jan-11 23:42pm    
Hey man, He gave you correct answer.
Here come to your confusion point. Actually if you want set a startup form for application then you need to mention that in the code. Normally people set the 'login form/splash screen' as startup form in their applications. Now you go ahead, that's all. Let us know if you still have any doubt.
jerrykid 19-Jan-11 23:37pm    
Please provide more about your problem, 2 forms in where? And run form2 to where? Your question is not clear
ks ravi 20-Jan-11 0:05am    
hi thatraja,

thanks for reply, then every time we have to change startUp form to run desired Form.

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