Calling parents functions

  • Thread starter Thread starter Gav
  • Start date Start date
G

Gav

Hi all,

Is it possible to call a mdicontainer's function from a child window?

Basically I have an function in the main MDIContainer form which opens child
forms, it accepts an enumerator to know which form to open, also it checks
to see if the form is already open so that it doesn't open it more than
once. I want one of my child forms to open a different child form by calling
this function.

Any help would be great

thanks
Gav
 
Hi Gav,
Yes you can call MDIContainer function from child form. You can go by 2
approach
1) You can declare a shared property for MDI form which creates a single
instance for MDI form for any number of call and through that shared Property
Instance of MDI form you can call any Public function

2) For any form you have MDIParent property, So use the following code to
get the MDI form and invove the function.

Dim objFrm As MDIForm
objFrm = ChildForm.MdiParent
objFrm.PublicFunction ' Public function available on the MDI form

The code is given in VB.net please convert them to c# if you want in c#. For
c# you need to type cast the form to MDI form before assigning

Regards
Sen
 
Thanks for the help Senthamil thats great

Senthamil said:
Hi Gav,
Yes you can call MDIContainer function from child form. You can go by 2
approach
1) You can declare a shared property for MDI form which creates a single
instance for MDI form for any number of call and through that shared
Property
Instance of MDI form you can call any Public function

2) For any form you have MDIParent property, So use the following code to
get the MDI form and invove the function.

Dim objFrm As MDIForm
objFrm = ChildForm.MdiParent
objFrm.PublicFunction ' Public function available on the MDI form

The code is given in VB.net please convert them to c# if you want in c#.
For
c# you need to type cast the form to MDI form before assigning

Regards
Sen
 
Gav said:
Is it possible to call a mdicontainer's function from a child window?

\\\
DirectCast(Me.MdiParent, MainForm).StatusBar1.Text = "Hello World!"
///
 
Back
Top