Change initial form displayed. From form1 to form2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • garyusenet@myway.com

    #1

    Change initial form displayed. From form1 to form2

    I have a windows form project which originally contained one form, the
    standard form. Form1.

    I've added another form now, form2 which i'm experimenting with.

    I'd like to display form2 when i run the application instead of form1.

    How do i do this?

    I know this must be a frequent request, but i've searched and can't
    find a straightforward explanation (which i'm sure must exit!)

    Thankyou,

    Gary-

  • Marc Gravell

    #2
    Re: Change initial form displayed. From form1 to form2

    Look for a static Main method; in 1.1 I believe this used to go into
    Form1.cs when auto-generated; in 2.0 it tends to live in Program.cs.
    In an auto-generated method it basically just does an Application.Run
    on a new instance of Form1; so change it to your desired form. Note
    that the project properties can be used to disambiguate if there are
    multiple eligible Main methods that look like an entry-point.

    Marc


    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: Change initial form displayed. From form1 to form2

      Hi,

      And the answer is even simplier, look for your Main method and change this
      line from:

      Application.Run (new Form1());

      To:

      Application.Run (new Form2());



      --
      Ignacio Machin
      machin AT laceupsolutions com


      <garyusenet@myw ay.comwrote in message
      news:1166711741 .614701.48410@f 1g2000cwa.googl egroups.com...
      >I have a windows form project which originally contained one form, the
      standard form. Form1.
      >
      I've added another form now, form2 which i'm experimenting with.
      >
      I'd like to display form2 when i run the application instead of form1.
      >
      How do i do this?
      >
      I know this must be a frequent request, but i've searched and can't
      find a straightforward explanation (which i'm sure must exit!)
      >
      Thankyou,
      >
      Gary-
      >

      Comment

      Working...