本文介绍了ObjectDisposedException已处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法访问已处置的对象.
对象名称:"frmBill".

Cannot access a disposed object.
Object name: ''frmBill''.

private void distributorBillToolStripMenuItem_Click(object sender,System.EventArgs e)
       {

           frmBill objfrmBill = frmBill.GetChildInstance();
           objfrmBill.MdiParent = this;
           objfrmBill.Show();
           objfrmBill.BringToFront();

       }

推荐答案


private void distributorBillToolStripMenuItem_Click(object sender,System.EventArgs e)
        {

            if (objdisbill != null)
            {
                objdisbill = frmDistributorBill.GetChildsInstance();
                objdisbill.MdiParent = this;
                objdisbill.WindowState = FormWindowState.Normal;
                objdisbill.BringToFront();
            }
            else
            {
                objdisbill = new frmDistributorBill();
                objdisbill.FormClosed += delegate { objdisbill = null; };
                objdisbill.Show(this);
            }

        }


这篇关于ObjectDisposedException已处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 22:28