Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make one form load before the other in C#?

Tags:

c#

winforms

I have two forms in a visual C# forms application. I want to load one form before the other, however it automatically loads form1 first (even though that's the one I want to have load second).

How do I change that?

like image 782
Alper Avatar asked Jun 05 '11 17:06

Alper


2 Answers

Look at Program.cs, which will probably have something like:

Application.Run(new Form1());

Change that to start with the second form.

like image 162
Jon Skeet Avatar answered Oct 13 '22 09:10

Jon Skeet


you need to modify Program.cs here is sample

  static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }

it is loading Form1.cs by default you can set to load any form

If i want to launch MyForm.cs then i would change it like

Application.Run(new MyForm());
like image 20
Afnan Bashir Avatar answered Oct 13 '22 08:10

Afnan Bashir