winforms - Even though form3 is created from form2, why it is not disposed on form2 close? -


I need your help to clarify whether the form is exactly like an object?

If I make an object obj 2, then oz 1 Obj2 will be disposed of obj1.

Although this is not the case with the case & amp; Give the pseudo code down.

I have three forms; Form1, form2 & amp; Form2.

form1 is the startup form I will make a form 1 and how to create a form 2 and to 2 & amp; Show form 3 using one button in each form.

If I close Form 3, after opening all 3 forms, I am able to work in Form 1 and Form 3.

Form 1


  public class form1 personal sub cmdOpenForm2_Click (ByVal, as in this System.Object, ByVal E) System.EventArgs handles as cmdOpenForm2.Click dim frm frm with new form2 '' / as. MdiParent = frmMain .how (). End with the BringsToFront () end sub-private sub form1_Disposed (ByVal as the object, as byVal E. System.EventArgs) handles Me.Disposed '' //frmMain.tsStatus.Text = "Form1 Settlement", The End Sub Class,  

Form 2


  Public Class Form 2 Private All CMDandClClClCl (As the system's Sub-sender.Object, by Value E. System. EventArgs) handle cmdRandomColor.Randomize () Label1.ForeColor = Color.FromA rgb (round *) 255, round () * 255, round () * 255, Raou E () * 255) End Sub Private Sub Form2_Disposed (ByVal) handles Me.Disposed frmMain as this object, ByVal e System.EventArgs. TsStatus.Text = "Form2 Settlement" End Sub Personal sub cmdOpenForm3_Click (byVal handle this as System.Object, as byVal e System.EventArgs) handle cmdOpenForm3.Click dimfm new form3 as 'frm' with // .mdiParent = frmMain .show (). End with bdtofront () end and end and class  

form 3


  Public Class Form 3 Private Sub CMDRendamColorGlick (ByVal, as ByVal e System.EventArgs) handle cmdRandomColor.Click random () Label1.ForeColor = Color.FromArgb (round () * 255 , Round () * 255, Round () * 255, Round () * 255) End Sub Personal Sub Form3_Disposed (ByVal, as the object, byVal E. System.EventArgs) Handle Me.Disposed frmMain.tsStatus.Text = "Form3 Settlement" means Last sub-termination class  

Any help would be greatly appreciated.

Thank you everyone for the solution

Sorry to mention, I'm not looking for a solution that How to remove form3 to close Form 2 .

I am interested in what is happening behind ... Is there a possibility that the 2GC collected from Form 3 example and I get a memory error.

Because I am protecting memory access exceptions in my actual application, which is not properly designed, and it is now too big for a refactor.

My question Where is the form3 example created? Is this in Form 2 instance or elsewhere because after the disposal of Form 2, I can get an example of Form 3. I suspect that it is made in elsewhere

The structure is still on your form object, when Stops until you can get a reference using it.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -