创建父窗体form1:
注意: 1).IsMIdContainer属性改为true(默认为false)--获取或设置一个值,该值指示窗体是否为多文档界面 (MDI) 子窗体的容器
创建子窗体formchid1,formchid2,formchid3,formchid4,在父窗体form1中创建4个按钮button1,button2,button3,button4 分别打开上面4个子窗体
3.父窗体部分代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
formchid1.MdiParent = Me
'formchid1.TopLevel = False
'formchid1.Parent = Me
formchid1.Dock = DockStyle.Fill
formchid1.Show()
formchid1.BringToFront()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
formchid2.MdiParent = Me
'formchid2.TopLevel = False
'formchid2.Parent = Me
formchid2.Dock = DockStyle.Fill
formchid2.Show()
formchid2.BringToFront()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
formchid3.MdiParent = Me
'formchid3.TopLevel = False
'formchid3.Parent = Me
formchid3.Dock = DockStyle.Fill
formchid3.Show()
formchid3.BringToFront()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
formchid4.MdiParent = Me
'formchid4.TopLevel = False
'formchid4.Parent = Me
formchid4.Dock = DockStyle.Fill
formchid4.Show()
formchid4.BringToFront()
End Sub