12

I'm a beginner c# programmer, and i'm getting familiar with the Windows Forms App. I have 2 forms and i'm trying to understand how to set one of them to be the first one that appears when i'm running the application.

Is there a way to set this, or I have to create the forms by the order they appears?

LarsTech
  • 80,625
  • 14
  • 153
  • 225
Tamar Cohen
  • 1,272
  • 2
  • 16
  • 28
  • 1
    Are you trying to make one appear first or on top? The answer below is good for the being first. Consider z-order for putting one on top of the other http://stackoverflow.com/questions/6049927/windows-form-objects-appear-infront-of-other-items – kenny Nov 25 '12 at 16:45

4 Answers4

37

In Program.cs, you will see the following line of code

Application.Run(new Form1());

This line shows Form1.
You can change it to do whatever you want.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

In Program.cs, you will see the following line of code

Application.Run(new Form1()); This line shows Form1. You can change it to do whatever you want.

fakhir ali
  • 11
  • 1
0

Write in Program.cs

Application.Run(new YourMainForm()); 
Frank59
  • 3,141
  • 4
  • 31
  • 53
0

In your visual studi, when ever you open a project by default program.cs will open.

   static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

you can see above Application.Run(new Form1());

whatever your form name is type there, then whenever you are starting first this form will run

Sohail
  • 780
  • 3
  • 14
  • 27