Accessing Controls on a MDI Parent from an MDI Child

cmanning

Newcomer
Joined
Feb 18, 2003
Messages
8
I have a MDI child that when closed need to uncheck a submenu control in my MDI Parent form. What code do I need to use to do this?
 
You need to cast it to the correct type before you can access members of it, e.g.

C#:
((frmMain)this.MDIParent).Property = value;
 
This is the message I get when I enter the above code...

"An unhandled exception of type 'System.NullReferenceException' occurred in NGRCommOps.exe

Additional information: Object reference not set to an instance of an object."

This is the code I entered to mirror what is aboce.
((fclsMain)this.MdiParent).mnuAdminTool.Checked = false;

Thoughts. Any help you can give is appreciated. Am I missing a callout.
 
Are you making sure to put this code inside one of the MDI children,
ranther than inside the MDI parent?
 
Ah; try putting it in the 'Closing' event. I believe that in the 'Closed'
event, the form no longer exists, and therefore cannot be used like
that.
 
same error. grrrrrr.....
do i need to reference the already existing method of the fclsMain MDI Parent ?
 
Back
Top