[求助]动态调用Form?
我想实现调用动态表单:(表单名称为from***)string zdk="from"+mc;//mc是变量string
zdk zdkhcnew = new zdk();
zdkhcnew.ShowDialog();
这样写好象不行,调试出错:
错误 1 找不到类型或命名空间名称“zdk”(是否缺少 using 指令或程序集引用?)
private void button1_Click(object sender, EventArgs e)
{
string a = "Form2";
Form form = null;
form = Formshow(a);
if (form != null)
{
form.ShowDialog();
form.Text = a;
}
}
private Form Formshow(string a)
{
Form newform = null;
try
{
newform = (Form)Assembly.Load("WindowsApplication1").CreateInstance("WindowsApplication1." + a);
}
catch(Exception err)
{
Console.WriteLine(err.Message);
}
return newform;
}
[此贴子已经被作者于2006-10-19 14:36:11编辑过]