Changing the startup form in a C# project

Open the C# project properties. In the "Application" tab set the Startup object to "WindowsFormsApplication1.Program". The "WindowsFormsApplication1" reflects the name of your current C# project so it could be different than the project name presented here.

Then in the solution explorer, under the project tree, open the "Program.cs" file. The code should be similar as follows:

static class Program
{
///


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

By modifying the "Application.Run(new Form1());" command, you can set the startup form. As an example if you want "Form2" to be set as the startup form your must change the code "Application.Run(new Form1());" to "Application.Run(new Form2());"

Labels: ,