Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i have form1, form2,form3 or more but start up form1 why please help me
Posted

Look at your application's entry point (usually "Main"). It has the line:

C#
Application.Run(new Form1());


This start of application defines what is your main form. When you close a main form, the whole application quits (unless you handle FormClosing event to cancel it).

If you want to show other forms, you need to… well, show them:

C#
//pretty sloppy code:
Form newForm = new Form2();
newForm.Show();

//more accurate code:
Form mainForm = new Form1();
Application.Run(mainForm);
Form newForm = new Form2();
mainForm.AddOwnedForm(newForm);
newForm.ShowInTaskbar = false;
newForm.Show();


Making a form owned by a main form makes them activate together, which help integrity if application behavior. In this way, no window from other application can appear in Z order between the forms of your application. Not showing a form in a task bar complements this behavior. In this way, only a main form represents whole application it the task bar.

See: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].

—SA
 
Share this answer
 
You can change it....

Go to program cs.

and change like as follows:

Application.Run(new Form2());
 
Share this answer
 
v2
Comments
shakil442 18-Jun-11 11:19am    
thanks
in solution explorer

right click on project title
go to properties

in that one of the menu

u will find option called
'startupobject' - by default it set 'Form1'

u can change it to ur requirement

which is very much useful in console applications

-try to observe it
 
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