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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
pedaammuluPosted Apr 15, 2007, 10:18 AM
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
YousefPosted Apr 14, 2007, 9:57 PM
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!
Simon FreedomPosted Apr 13, 2007, 8:38 AM
John Charles OlamendyPosted Apr 12, 2007, 4:22 PM