简体   繁体   English

如何阻止表单加载c#windows窗体

[英]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. 我有一个Windows窗体应用程序,它要求用户在加载整个表单之前登录。 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());. 在cancel_Click()方法中我调用this.Close(),但它在Application.run(new Form1());中生成异常。 I treid with this.Dispose() and Application.exit() also but didnt worked. 我喜欢这个.Dispose()和Application.exit()但也没有用。 Please help me 请帮我

Thanks in Adv. 谢谢Adv。

The following link might help you solve the problem: 以下链接可帮助您解决问题:

C#: How to prevent main form from showing too early C#:如何防止主表单显示得太早

Hope this helps... 希望这可以帮助...

    public static void Main()
    {
        using (var signInForm = new SignInForm())
        {
            if (signInForm.ShowDialog() != DialogResult.OK)
                return;
        }
        Application.Run(new MainForm());
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Windows 窗体 C# 中执行代码时显示动画加载窗体 - How to show an animated loading form while executing code in Windows Forms C# 如何停止在C#表单应用程序的构造函数中加载表单 - How to stop loading a form in constructor in C# form application c#如何在加载表单之前阻止“ CheckBox CheckedChanged”启动? - c# How do I stop “CheckBox CheckedChanged” from firing prior to form loading? 无法在Windows窗体C#中加载图像 - Trouble loading images in windows forms C# 如何在 C# 中调整 Windows 窗体窗体的大小? - How do I resize a Windows Forms form in C#? 如何在C#Windows窗体中的特定位置放置打开窗体? - How to position the opening form at specific location in C# Windows Forms? 如何在C#Windows窗体中创建选项窗体? - How to create an options form in C# Windows Forms? 如何使 Windows Forms C# 中的表单不可点击? - How to make a Form in Windows Forms C# not Clickable? 如何使用 dto 将信息从一种形式传输到另一种形式,C# Windows Forms? - How to transport information from one form to another using dto, C# Windows Forms? 如何在C#中停止从windows.form应用程序调用的类函数 - how to stop class function called from a windows.form application in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM