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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.