十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
直接添加一个MID父窗体或在已有窗体的属性中找到IsMDIContainer属性,然后设置为True,然后创建第二个窗体 ,需要加载子窗体的时候:
创新互联是专业的峨眉山网站建设公司,峨眉山接单;提供成都网站建设、网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行峨眉山网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
Dim NewMDIChild As New Form2
NewMDIChild.MdiParent = Me
NewMDIChild.Show()
Public Shared Sub CheckMDIChildForm(ByVal MDIForm As Windows.Forms.Form, ByVal MDIChildForm As Windows.Forms.Form, ByVal MDIChildFormName As String)
If MDIForm.MdiChildren.Length 1 Then
'如果没有任何一个MDI子窗体,则创该MDI子窗体的窗体实例
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
Exit Sub
Else
Dim x As Integer
Dim frmyn As Boolean
For x = 0 To (MDIForm.MdiChildren.Length) - 1
Dim tempChild As Windows.Forms.Form = CType(MDIForm.MdiChildren(x), Windows.Forms.Form)
If tempChild.Name = MDIChildFormName Then
'检测到有该MDI子窗体,设为激活 并退出循环
frmyn = True
tempChild.BringToFront()
Exit For
Else
frmyn = False
End If
Next
If Not frmyn Then
'在打开的窗体中没检测到则新建
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
End If
End If
End Sub
窗体 Form1)
Me.Size = New Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
(子窗体 Form2)
Me.Size = New Size(Screen.PrimaryScreen.WorkingArea.Width / 4, Screen.PrimaryScreen.WorkingArea.Height)
这不就是MDI吗?把主窗口的IsMdiContainer属性设置为True,然后在加载子窗口的时候加上一句:
子窗口.MdiParent = 主窗口
然后再Show就行了.
示例:
Private Sub b1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.Click
Dim frm As New Form2
frm.MdiParent = Me
frm.Show()
End Sub
你的情况应该是窗体中嵌入子窗体吧:
主窗体.IsMdiContainer = True
Dim 子窗体 As New Form
子窗体.TopMost=False
子窗体.Show()
子窗体.MdiParent = 主窗体
如果不是嵌入窗体captain2005的回答应该没问题,或者你在被覆盖的窗体上:
子窗体.TopMost = True ‘将子窗体设为顶层显示