父窗体调用子窗体的sub 保存
父窗体的menuitem中有个保存,我先判断一下是哪个子窗体活动,然后就调用那个子窗体的sub save ,不会写
虽然是个很简单的问题,不过请高人给我指点一下
[解决办法]
Public Class mainForm
Dim sonform As Form
Private Sub 保存ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 保存ToolStripMenuItem1.Click
For Each sonform In Me.MdiChildren
'在这里保存你想要保存的东西
Next
End Sub
Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oneForm As New sonFormOne() '子窗体
Dim twoForm As New sonFormTwo() '另一个字窗体
oneForm.MdiParent = Me
twoForm.MdiParent = Me
oneForm.Show()
twoForm.Show()
End Sub
End Class
[解决办法]
[code=VB.NET][/code] Dim frmChild As Form = Me.ActiveMdiChild
If frmChild IsNot Nothing Then
If frmChild.GetType Is GetType(Form1) Then
CType(frmChild, Form1).save()
ElseIf frmChild.GetType Is GetType(Form2) Then
CType(frmChild, Form2).save()
End If
End If