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());”

 


Get Started with .NET Programming Fast and Easy!

Check our online course titled “.NET Programming for Beginners – Windows Forms with C#” (special limited-time discount included in link).

.NET Programming for Beginners: Windows Forms (C#) - Online Course

Learn how to implement Windows Forms projects in .NET using Visual Studio and C#, how to implement multithreading, how to create deployment packages and installers for your .NET Windows Forms apps using ClickOnce in Visual Studio, and more! 

Many live demonstrations and downloadable resources included!

Learn More


 

Featured Online Courses:

 

Read Also:

 

Did you find this article useful and interesting?

Interested in SQL Server Administration? Find hundreds of useful SQL Server administration and troubleshooting articles in 9 Times Microsoft Data Platform MVP, Artemakis’ Artemiou eBook: “Administering SQL Server (Second Edition)“.

Check our other related .NET articles.

Check out our latest software releases!

Subscribe to our newsletter and stay up to date!

 

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Loading...

Reference: SQLNetHub.com (https://www.sqlnethub.com)

© SQLNetHub