|
-
Oct 30th, 2002, 05:14 AM
#1
Thread Starter
Fanatic Member
Calling sub in mdi child
hi
recently i started vb.net was wounding if any one can help me..
i have a small dout
in vb6 if we have a mdi app and each child form has a public sub assign(which is used for saving)
we can call the sub by
Me.ActiveForm.ASSIGN
how do we do this in vb.net
any tips.. thanks
-
Oct 30th, 2002, 08:15 AM
#2
Hyperactive Member
There are a few ways to do this. The method I have used in the past is to use an Inherited form for the mdi children.
ie,
a) Create a form called something like frmAbstractMdiChild, with no controls, and one public overridable sub called "Assign".
When I did it I actually had many overridable subs (Print, Save, Refresh etc) - and I also had a few controls common to all the mdi children - such as a statusbar.
b) When you create the mdi child form - create it as inherited from frmAbstractMdiChild.
c) From your mdi parent -when you wish to process the common Assign method, you can now do something like this.
VB Code:
Dim oForm As frmAbstractMdiChild
oForm = CType(Me.ActiveMdiChild, frmAbstractMdiChild)
oForm.Assign
d) If you wish for common Assign code - then it can be placed in the Assign Sub of the Abstract form, otherwise you can have a "Protected Overrides Sub Assign" in each mdi Child.
Of course the code in the parent form will only work if all the mdi children have been inherited from the abstract form, but you could get around that by code. ie, if you called all the children that use the inherited form "frmChildxxx" you could test for the form name starting with "frmChild"
ie,
VB Code:
If Not Me.ActiveMdiChild.Name.StartsWith("frmChild") Then Exit Sub
There are no doubt easier ways to do this - especially if you had Option Strict Off (I prefer it on personally) - but then I was using inherited forms anyway - so it worked well for me.
Hope this has helped.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|