16,717
社区成员
发帖
与我相关
我的任务
分享 Private Sub ULoadSubFormAll()
Dim ctl As Control
For Each ctl In ToolStripContainer1.Controls
If (TypeOf (ctl) Is System.Windows.Forms.Form) Then '窗体已不再是窗体,而是一个类,咋办?
ToolStripContainer1.ContentPanel.Controls.Remove(ctl)
End If
Next
End Sub Public Sub LoadSubForm(ByVal frm As Form, ByVal ctlParent As Control)
frm.TopLevel = False 'Form类源于control类,因此有这个属性
frm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
frm.Parent = ctlParent
frm.Dock = DockStyle.Fill
'frm.AutoSize = True
'frm.AutoSizeMode = AutoSizeMode.GrowAndShrink
ctlParent.AutoSize = True
frm.Show()
End Sub
Public Sub ULoadSubForm(ByRef frm As Form)
If frm IsNot Nothing Then
frm.Close()
End If
End SubLoadSubForm(CType(frmLogin, Form))'加载时强制转换成Form,然后在卸载时就出现了上面的问题(找不到Form)