Call function of current active child from MDIParent in VB.Net

5 pts.
Tags:
VB.NET
Dim value As Form Dim i As Integer value = Me.ActiveMdiChild after getting the current active child i want to call function of that child but dont want to mention its name(like form1, form2). For example i want to call this way value.Func(). I dont want to use CType(value, Form1).Func() How can i do this? Infect my requirement is that if user press save button of MDIForm then Save function of currently active child should be called. Child can be any of form1, form2, form3...thats y i dont want to mention name of form specificly. Plz help me.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I just did this:
<pre>
If TypeOf Me.ActiveMdiChild Is AccountForm Then
Dim ChildForm As AccountForm = CType(Me.ActiveMdiChild, AccountForm)
ChildForm.MethodOfChildForm
End If
</pre>

I don’t quite understand the question. MDIChildren are of usually one type (say “MyDerivedForm” or “Form2″ or whatever. Then you can certainly do stuff like:
Dim fm as MyDerivedForm = Me.ActiveMDIChild
If fm Is Nothing
MsgBox(“No Active Children”,0,””)
Else
dim i as integer = fm.Foo()
End If
or call up a child button using fm.SaveButtonCick(sender,e) assuming not private
or call up a MenuStrip item, if you have not merged it, as, for example fm.SaveToolStripMenuItem.PerformClick()
and so on.
All easy stuff but your question seems to imply different TYPES in the way you talk about “Form1″, “Form2″ etc.
Perhaps I need more clarification.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Shaileshk
    Hi Dear, I found the solution from the below website http://codegroups.com/blog/index.php/configure-parent-and-child-form-using-mdi-on-visual-studio-2005/ if you still have problem then let me know. Thanks, Shaileshk
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following