Dim asm As [Assembly] = System.Reflection.Assembly.GetExecutingAssembly()
Dim frm As New Form
'这一步和C#有区别,C#不需要写项目名称的
frm = asm.CreateInstance("项目名称." + 数据库读出来的窗体名称)
frm.show
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <param name="NewForm">新窗口的名字</param>
''' <param name="NewWindow">是否打开新窗口,默认激活(该窗口唯一)</param>
''' <param name="MaxWindow">该窗口是否最大化,必须是新增窗口</param>
''' <remarks>
''' </remarks>
''' <history>
''' [蒋玉龙 QQ:66840199] 2006-11-20 Created
''' </history>
''' -----------------------------------------------------------------------------
Private Sub AddWindow(ByVal NewForm As String, Optional ByVal NewWindow As Boolean = False, Optional ByVal MdiMaxWindow As Boolean = True, Optional ByVal ModMaxWindow As Boolean = False)
If LargeImgBar.Buttons.Item(1).Pushed = True Then
'打开模式窗口
Dim asm As [Assembly] = System.Reflection.Assembly.GetExecutingAssembly()
Dim frm As New Form
frm = asm.CreateInstance("LdAsset." + NewForm)
CType(frm, Common).MdiWindow = False '不记录下拉框打开的窗体集合
frm.StartPosition = FormStartPosition.CenterScreen
If ModMaxWindow = True Then frm.WindowState = FormWindowState.Maximized
frm.ShowDialog()
Else
'检查是否已经存在了
Dim II As Long, tempChild As Form
If NewWindow = False Then
For II = 0 To Me.MdiChildren.Length - 1
tempChild = CType(Me.MdiChildren(II), Form)
If tempChild.Name = NewForm Then
tempChild.Focus() : Exit Sub
End If
Next
End If
' 也可以用反射动态加载其他的assembly
Dim asm As [Assembly] = System.Reflection.Assembly.GetExecutingAssembly()
Dim frm As New Form
frm = asm.CreateInstance("LdAsset." + NewForm)
frm.MdiParent = Me
frm.StartPosition = FormStartPosition.WindowsDefaultLocation
CType(frm, Common).MdiWindow = True '记录下拉框打开的窗体集合
If MdiMaxWindow = True Then frm.WindowState = FormWindowState.Maximized
frm.Show()
'根据索引设置列表
End If
End Sub