參考
--
最近在開發新案子,重架選單;卻發現子視窗關閉後再重新打啟一次,竟會位移(x,y)遞增式
自己也是調整ok , 倒是查了一下;底下這方法較OK!
--
Public Sub NewFormInstance(ByVal FormType As Type, ByVal MDIParent As Form)
'MAKE SURE MDI FORM IS VALID INSTANCE AND HAS MDICONTAINER SET TO TRUE
If MDIParent IsNot Nothing AndAlso MDIParent.IsMdiContainer = True Then
Dim myMDIChildForm = CType(Activator.CreateInstance(FormType), Form)
myMDIChildForm.MdiParent = MDIParent
myMDIChildForm.StartPosition = FormStartPosition.Manual
myMDIChildForm.Location = New Point(0, 0)
myMDIChildForm.Show()
myMDIChildForm.BringToFront()
End If
End Sub
and would be used in the MDI Parent form like this:
NewFormInstance(GetType(Form2), Me) 'new instance of form2
NewFormInstance(GetType(Form3), Me) 'new instance of form3
沒有留言:
張貼留言