Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a form from loading in c# windows forms

I've a windows form application where it ask the user to login before loading the entire form. If the user cancel the login then i've to stop the form loading and quit the application. In cancel_Click() method im calling this.Close(), but it is generating exception at Application.run(new Form1());. I treid with this.Dispose() and Application.exit() also but didnt worked. Please help me

Thanks in Adv.

like image 543
user626660 Avatar asked Feb 01 '26 19:02

user626660


2 Answers

    public static void Main()
    {
        using (var signInForm = new SignInForm())
        {
            if (signInForm.ShowDialog() != DialogResult.OK)
                return;
        }
        Application.Run(new MainForm());
    }
like image 163
Alex Aza Avatar answered Feb 04 '26 11:02

Alex Aza


The following link might help you solve the problem:

C#: How to prevent main form from showing too early

Hope this helps...

like image 33
Dulini Atapattu Avatar answered Feb 04 '26 11:02

Dulini Atapattu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!