VB.Net文本转窗体名称实例
Dim Formname As String = "项目名称." +需转换的文本.ToString.Trim '//需转换的文本,可以是控件的TEXT,也可以是数据库取值
Dim Mytype As Type = Type.GetType(Formname)
Dim F As Form = CType(System.Activator.CreateInstance(Mytype), Form)
例如:
Try
Dim Formname As String = "CRMSServer." + TreeView1.SelectedNode.Text.ToString.Trim
Dim Mytype As Type = Type.GetType(Formname)
Dim F As Form = CType(System.Activator.CreateInstance(Mytype), Form)
F.WindowState = FormWindowState.Maximized
F.Text = TreeView1.SelectedNode.Text
F.TopLevel = False
F.Parent = Me.Panel1
' Me.SplitContainer3.Panel2.Controls.Add(F)
F.Show()
Catch ex As Exception
' MsgBox(ex.Message.ToString)
End Try