本文介绍了单实例子窗体不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

frmSChild objfrmSChild = frmSChild.GetChildInstance();
objfrmSChild.MdiParent = this;
objfrmSChild.Show();
objfrmSChild.BringToFront();



一切正常.但是它只能工作一次.

我打开那个frmSChild 2或3次.它将提出该表格.
但是,如果我关闭该表格并再次打开.出现错误,指出无法访问已处置的对象.对象名称:"frmSChild ..."



It is working fine. But it only works once.

I open the that frmSChild for 2 or 3 times. it will bring forwards that form.
But if I close that form and open again. there is an error stating "Cannot access a disposed object. Object name: ''frmSChild..."
How to modify the code to get it done?

推荐答案

protected override void Dispose( bool disposing )
{
    if( disposing )
    {
        if(components != null)
        {
            components.Dispose();
        }
    }
    base.Dispose( disposing );
    m_SChildform = null;
}




Valery.




Valery.




这篇关于单实例子窗体不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 08:12