Public Class Form1 '作者:章鱼哥,QQ:3107073263 群:309816713 '如有疑问或好的建议请联系我,大家一起进步 '声明SetParent函数,这是一个API函数 Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Long Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.IsMdiContainer = True '将Form1设置为父窗体容器 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Form1是父窗体,Form2是子窗体 SetParent(Form2.Handle, Me.Handle) Form2.Show() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click SetParent(Form3.Handle, Me.Handle) Form3.Show() End Sub End Class
截图效果: