Question : MDI Parent Object Reference?

Hello,
I have an MDI application. In an MDI Child Form, I obtain a reference to the MDI Parent Form like this:
MDIParentForm pform = (MDIParentForm)this.MdiParent;

Now, I have an object that holds a reference to this form, so next line I instanciate the objcect
MyObject obj = new MyObject(pform);

My questions are:
Am I actually passing a reference to the Parent Form, or a copy? Does it matter?
What should I do with pform at the end of this method? Set it to null?

Thanks.

Answer : MDI Parent Object Reference?

>Am I actually passing a reference to the Parent Form, or a copy? Does it matter?
You are passing the reference to the parent form.

With this reference, you can do anything to the parent form, except for instantiating it.
What I mean is if in your MyObject, you execute:
    pform = new Form();
the original parent form won't budge.


>What should I do with pform at the end of this method? Set it to null?
Not necessary. The variable pform in the method is local to the method, it will be removed automatically once the method ends.
Random Solutions  
 
programming4us programming4us