Help in CSharp menu...

N

NAF

First I want to ask sorry for my poor English.



This is my problem.

I have a method inside the MDI parent Form

public void SetMenus()

{

--------

}



--------------------------------------------------------------------------------------

frmSave objSave = new frmSave();

objSave.MdiParen t= this;

objSave.ShowDialog();



I want to call the SetMenus() method of parent class before close the
objSave (MdiChild form)



Can any one help me to solve this problem?



NOTE: Also I need some help regarding the enable disable drop down tool
strips menu item. I mean I want to disable some menu items/ Enable some menu
items when I load a particular form. If there is any resources/ Example
regarding this, please send it to me.



Thanks in Advanced



I am a beginner of C# programming.
 
P

Peter Duniho

[...]
I have a method inside the MDI parent Form

public void SetMenus()

{
}

--------------------------------------------------------------------------------------

frmSave objSave = new frmSave();

objSave.MdiParent = this;

objSave.ShowDialog();

I want to call the SetMenus() method of parent class before close the
objSave (MdiChild form)

Can any one help me to solve this problem?

To call an instance method, you need a reference to an instance of the
object. In this case, to a specific instance of the object (i.e. the
"this" in your very vague code example).

So, either cast the "MdiParent" property value back to the appropriate
type (i.e. the actual parent form's class, where the "SetMenus()" method
exists), or store it as the needed type as a separate member in your child
form class.

Since the MDI child form does already have an obvious member where the
reference is already stored, I would generally prefer to take that
approach, casting the reference as needed to call "SetMenus()". But
there's not really anything fundamentally wrong with the second approach
either.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top