在VB.net中,将值从子窗体(child)传递给多文档界面(MDI Parent)的方法如下:
Public Class ChildForm
Public Property ValueToPass As String
End Class
Public Sub PassValueToParent()
Dim parentForm As MDIParent1 = CType(Me.ParentForm, MDIParent1)
parentForm.ValueFromChild = ValueToPass
End Sub
Public Class MDIParent1
Public Property ValueFromChild As String
End Class
Public Sub HandleValueFromChild()
' 处理从子窗体传递的值
End Sub
Private Sub ChildForm_FormClosed(sender As Object, e As FormClosedEventArgs) Handles ChildForm.FormClosed
HandleValueFromChild()
End Sub
PassValueToParent()
方法即可。例如:Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ValueToPass = TextBox1.Text
PassValueToParent()
End Sub
通过以上步骤,您可以在VB.net中将值从子窗体传递给多文档界面(MDI Parent)。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云