不使用C#.net返回表单名称 [英] does not return the Form name using C#.net

查看:88
本文介绍了不使用C#.net返回表单名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//formname包含值("EditFrom")
//但以下returnFromName显示为空

returnFromName =(FormClas)Assembly.GetEntryAssembly().CreateInstance(formname);

//formname contains the value ("EditFrom")
//but the following returnFromName shows null

returnFromName=(FormClas)Assembly.GetEntryAssembly().CreateInstance(formname);

推荐答案

您需要传递全名.
http://msdn.microsoft.com/en-us/library/dex1ss7c.aspx [ ^ ]

全名是My.Namespaces.MyForm
You need to pass the full name.
http://msdn.microsoft.com/en-us/library/dex1ss7c.aspx[^]

The full name would be My.Namespaces.MyForm


在我看来,您在设计时具有Form的类型.您可以使用其他方法通过反射来创建表单,例如 Activator.GetInstance(Of frmMyForm) [ ^ ].
另请注意,实例化Form的最佳方法是仅调用构造函数.
像这样:
It seems to me that you have the type of the Form at designtime. You could use other methods to create your Form using reflection, like Activator.GetInstance(Of frmMyForm)[^].
Also note that the best way to instantiate a Form is by simply calling the constructor.
Like so:
frmMyForm frm = New frmMyForm();
frm.Show();


这篇关于不使用C#.net返回表单名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆