Share via


How to setup a startup form in Visual Studio using C#

Question

Thursday, May 6, 2010 9:03 PM | 1 vote

Hello Guru,

I'm newbie to C#.

I am using Visual Studio 2008 SP1 and create a project that has several win forms.

For instance:

  • frmMain.cs
  • frmProject.cs
  • frmVendorAgreement.cs
  • frmAgreement.cs

I run into problems to setup a startup form because I did not see my win froms displayed in Startup Object list.

Here is my steps:

1. Right click on Project

2. ApplicationStartup object:

Can someone help and advice.

Thanks,

Edwin

All replies (4)

Friday, May 7, 2010 3:41 AM âś…Answered | 2 votes

Hi,

In the program.cs you can mention the startup form. For eg., if u want to set frmMain as startup project then the code should be,

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

Sab


Thursday, May 6, 2010 9:34 PM

Hi,

what Type of C# Project you have? On a normal Windows Form Application, you can specify the Startup Form within your Main Function (normaly located in Program.cs).

Thomas

 

 


Friday, May 7, 2010 6:49 PM

Thamas and Sab,

Many thanks for your help.  It works now.

Sorry for delay to reply due to my email no longer can be accessed.

Thanks,

Edwin


Monday, November 12, 2012 11:00 PM

Hello Guru,

I'm newbie to C#.

I am using Visual Studio 2008 SP1 and create a project that has several win forms.

For instance:

  • frmMain.cs
  • frmProject.cs
  • frmVendorAgreement.cs
  • frmAgreement.cs

I run into problems to setup a startup form because I did not see my win froms displayed in Startup Object list.

Here is my steps:

1. Right click on Project

2. ApplicationStartup object:

Can someone help and advice.

Thanks,

Edwin

Thanks,