Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C# Change Default Form on Load

Options
  • 24-05-2008 12:52am
    #1
    Registered Users Posts: 1,987 ✭✭✭


    I want to change the default form that loads first from form1 to form2, cant remember how to do it in Visual Studio 2008, can anyone help?


Comments

  • Registered Users Posts: 2,150 ✭✭✭dazberry


    I'm not sure/can't remember if there's somewhere to do this in the IDE but you can change the Application.Run line in the program.cs file to run a different WinForm by default AFAIR.
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new [B]Form1[/B]());
            }
    

    D.


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    Nice one, that worked fine, just an other little question, i have
    this.Hide();
    
    on a button, how do i open another form that already exists, I've tried
    frmMain.Show();
    
    but it doesn't work, throws an error!?


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    Got it, thanks.


  • Registered Users Posts: 279 ✭✭kev_Makaveli


    Hi there. I dunno if this will help but i think u have to declare your new form
    Form2 myForm = new Form2();
    myform.show();
    


  • Closed Accounts Posts: 1 kevser


    hi,
    you can it from Program.cs,
    Application.Run(new Form2());

    Form2 is default form in this project.


  • Advertisement
Advertisement