当前位置:编程文档 >> VB.net >> VB.net通过窗体名称(字符串)来得到窗体的实例?
首页

VB.net通过窗体名称(字符串)来得到窗体的实例?

所属类别:VB.net
文章作者:AntingZ
推荐指数:★★★☆
文档人气:159
本周人气:1
发布日期:2007-3-4

方法一(Reflection):

Dim str As String
str = "myTest.Form2"  '必须是 命名空间+点+窗体类名
Dim tempAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim frm2 As Form = CType(tempAssembly.CreateInstance(str), Form)
frm2.Show()

方法二(Type.GetType() ):

Dim frmName, fullName As String
frmName = "form2"
fullName = Application.ProductName & "." & frmName
Dim frm2 As Form
frm2 = Activator.CreateInstance(Type.GetType(fullName, True, True))
frm2 .Visible = True

文档说明:

     

相关文档


读取评论列表……