Hello,
How can I change which form initially loads up in my C# application?
Thanks,
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
John Charles OlamendyRank #159 · 14.8K reputationPosted Apr 12, 2007, 12:22 PM EDT
Simon Freedom4 reputationPosted Apr 13, 2007, 4:38 AM EDT
Yousef27 reputationPosted Apr 14, 2007, 5:57 PM EDT
Ok, the short answer is, open your Program.cs file in your Windows Application, and look for the line:
Application.Run(new Form1());
Now Change "new Form1()" to "new MyForm()" where MyForm is the form you want to have loaded up initially.
If you need more tips go to http://www.mycsharpcorner.com
Hope this helps!
pedaammulu32 reputationPosted Apr 15, 2007, 6:18 AM EDT
When the application starts up, the first form to be displayed, has to be specified in the Project properties window. In C#, in the ‘Startup object’ drop down list box, the MenuForm option will not be displayed. So, to set the ‘Startup object’, select the class that contains Main( ) in the Project Properties dialog box. To do this, create a class, name it as you like (here i have given as finstart), and type the following:
using System;
using System.Collections.Generic;
using System.Text;
namespace FinCsharpProject
{ class FinStart
{ static void Main()
{ System.Windows.Forms.Application.Run(new MenuForm());
}
}
}
Now, in the Startup object drop down list box of the properties dialog box, FinStart classs will be displayed. Choose this option. When we run the application, the MenuForm will be displayed at startup.
Refer this book "Database programming using C#, vb 2005 and SQL Server 2005 on .Net Framework 2.0.", http://www.vkinfotek.com