确保您的属性IsMdiContainer
设置为True
,如果没有,您可以像加载表单时那样以编程方式设置它:
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
End Sub
您无需立即为您的 SalesNote 表单创建实例:
Public SNFrm As SalesNote
因为你在这里实例化它:
Private Sub MenuSalesNote_Click(......)
SNFrm = New SalesNote
SNFrm.MdiParent = Me
SNFrm.StartPosition = FormStartPosition.CenterScreen
SNFrm.Show()
End Sub
但是,如果您的SetLanguage()
过程在此之前被调用,MenuSalesNote_Click()
那么最好立即实例化它,或者您可以在此处实例化它:
Private Sub SetLanguage()
SNFrm = New SalesNote
SNFrm.Text = My.Resources....
SNFrm.AcceptBtn.Text = My.Resources...
End Sub
但是,您不再实例化它MenuSalesNote_Click()
:
Private Sub MenuSalesNote_Click(......)
SNFrm.MdiParent = Me
SNFrm.StartPosition = FormStartPosition.CenterScreen
SNFrm.Show()
End Sub
您还可以通过检查是否已经存在 SalesNote 表单的实例来实现这一点,例如:
Private Sub MenuSalesNote_Click(......)
If (SNFrm is Nothing) Then
SNFrm = New SalesNote
End if
SNFrm.MdiParent = Me
SNFrm.StartPosition = FormStartPosition.CenterScreen
SNFrm.Show()
End Sub
Private Sub SetLanguage()
If (SNFrm is Nothing) Then
SNFrm = New SalesNote
End if
SNFrm.Text = My.Resources....
SNFrm.AcceptBtn.Text = My.Resources...
End Sub