简体   繁体   中英

When we have multiple windows forms in our C# application, how to make one form as opening form

My application has two forms - Login and registration.

I have first coded registration form and when ever I start the application only registration form is coming. Is there any property I have to change or suggest way.Where I can make Login Form as start up form.

Go to your Program.cs and you will see

Application.Run(new RegistrationForm());

change the name of the form to LoginForm as follows:

Application.Run(new LoginForm());

Full code in Program.cs should look like this:

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

Note: Replace LoginForm() with the name of your Form

Find Program.cs in your project. It should have private static void Main(string[] args) method inside it and something like Application.Run(new RegistrationForm()); . Change it to Application.Run(new LoginForm());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM