不使用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();