0

Hey

Say I have a login and the main form.
If the login window is closed then the other form shouldn't load.
I tried using a if condition to suppress initializeComponent but it still shows the main form, but empty.
How would you do that?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Momerath
0

I would modify the Main method in Program.cs to something like:

[STAThread]
static void Main() {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    LoginForm lif = new LoginForm();
    Application.Run(lif);
    if (lif.Success) {
        Application.Run(new Form1());
    }
}

You'll need to add a property to your login form (in my example, Success) that lets you know if the user logged in.

Edited by Momerath: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.