简体   繁体   English

System.Windows.Forms.d中发生了类型为'System.ObjectDisposedException'的未处理异常

[英]An unhandled exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.d

I am working with visual studio 2012 C# windows form application. 我正在使用Visual Studio 2012 C#Windows窗体应用程序。 I am simply setting up my flow of forms by button_click events ie form1 has a button Click Next which will close current form and open a new form Form2. 我只是通过button_click事件来设置表单流程,即form1有一个单击Next的按钮,它将关闭当前表单并打开一个新表单Form2。 Form2 has a "Click Next" Button which takes to Form3 and so on. Form2有一个“单击下一步”按钮,该按钮进入Form3,依此类推。 In my forms, I am using form1.show() and form1.close() at required places. 在我的表单中,我在需要的位置使用form1.show()和form1.close()。 Please, look into this and replies are welcome.I am facing an Exception as An unhandled exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll Additional information: Cannot access a disposed object. 请仔细研究,欢迎您答复。我面临一个异常,因为System.Windows.Forms.dll中发生了类型为'System.ObjectDisposedException'的未处理异常。其他信息:无法访问已处置的对象。
MY program.cs is here 我的program.cs在这里

namespace WindowsFormsApplication1
{
    static class Program
    {

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Validate_Form());



        }
    }
}

In a Winform application, the window you specify in the Main method is your application's Main Form which gets associated with your Application's Process Handler in the OS (Windows). 在Winform应用程序中,您在Main方法中指定的窗口是应用程序的Main Form,该窗体与OS(Windows)中应用程序的处理程序相关联。 Processes can be categorized in 2 types. 流程可以分为两种类型。 Windowed processes and Windowless ones. 窗口进程和无窗口进程。 In a Windowed process, all the other forms in your application which are mapped to a Windows Window object will be a direct or indirect child of the main form of the application. 在Windowed进程中,应用程序中映射到Windows Window对象的所有其他窗体将是应用程序主窗体的直接或间接子级。 If you are designing a wizard as it looks it is what your are doing, my suggestion is to have your main form as a container and have the steps of the wizard as children gets loaded into your main form. 如果您正在设计看起来像向导的向导,那是您的工作,我的建议是将主表单作为容器,并在子进程加载到主表单时掌握向导的步骤。 For instance, you have a 2 step wizard: in this scenario, you will be needing 3 forms; 例如,您有一个两步向导:在这种情况下,您将需要3个表格; the main form and the 2 steps. 主要形式和2个步骤。 Main form will have the title and on the bottom area the navigation/control buttons (next/finish/cancel) and in the middle part of the form insert a container which loads the 2 steps. 主窗体将具有标题,在底部区域具有导航/控制按钮(下一个/完成/取消),并在窗体的中间部分插入一个容器,该容器可加载2个步骤。 you need to set the properties of the steps as Window = none and ChildWindow = true. 您需要将步骤的属性设置为Window = none和ChildWindow = true。 Now, when you load the main form, it loads the step 1 into its container area by setting the right child/parent relation in the main form's container object. 现在,当您加载主窗体时,它通过在主窗体的容器对象中设置正确的子/父关系将步骤1加载到其容器区域中。 Once user clicks on next, then you load the second form, hide the first one, and activate the second one. 用户单击“下一步”后,您将加载第二个表单,隐藏第一个表单,然后激活第二个表单。 I think you got the idea. 我想你明白了。 And this is how an actual wizard is designed. 这就是设计实际向导的方式。 Let me know if you had any other questions/concerns. 让我知道您是否还有其他问题/疑虑。

暂无
暂无

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

相关问题 System.dll 中出现“System.ObjectDisposedException”类型的未处理异常 - An unhandled exception of type 'System.ObjectDisposedException' occurred in System.dll 类型'System.ObjectDisposedException'的异常 - Exception of type 'System.ObjectDisposedException' 类型“ System.ObjectDisposedException”的异常在迭代后消失 - Exception of type 'System.ObjectDisposedException' disappears after iteration System.Windows.Forms.dll中发生了类型为'System.StackOverflowException'的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll “System.Windows.Forms.dll中发生了'System.StackOverflowException'类型的未处理异常” - “An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll” 生成报告导致在system.windows.forms.dll中发生类型为'system.stackoverflowexception'的未处理异常 - Generating report results in an unhandled exception of type 'system.stackoverflowexception' occurred in system.windows.forms.dll 错误:System.Windows.Forms.dll中发生未处理的“System.BadImageFormatException”类型异常 - Error: An unhandled exception of type 'System.BadImageFormatException' occurred in System.Windows.Forms.dll System.Windows.Forms.dll中发生类型为'System.ArgumentException'的未处理异常 - an unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll System.ObjectDisposedException UWP - System.ObjectDisposedException UWP System.ObjectDisposedException - System.ObjectDisposedException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM