المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Correctly Disposing of MDI Child Forms.



C# Programming
04-13-2012, 03:52 PM
I've got an issue with my MDI child forms, where the form objects 'contain' data from previous instances.

I'm assuming its relating to the fact that when I open the form from the MDI parent I use the following:
frmDTC frm = new frmDTC(true);frm.MdiParent = this;frm.Show();I think the errors are occurring because I don't dispose of frm. Usually I would use using, but that will close the form instantly.http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif

So should I do something like:
frm.FormClosed += (s, ev) => frm.Dispose();Or should this be in the form class itself?

Or have I missed something else...and the user closing the form should mean it gets disposed eventually...and I've got something else stopping it.