[C#] 纯文本查看 复制代码 /// <summary>
/// 打开新的子窗体
/// </summary>
/// <param name="strName">窗体的类名</param>
/// <param name="AssemblyName">窗体所在类库的名称</param>
public static void CreateForm(string strName, string AssemblyName)
{
string path = AssemblyName;//项目的Assembly选项名称
string name = strName; //类的名字
Form doc = (Form)Assembly.Load(path).CreateInstance(name);
doc.Show();
}
private void button1_Click(object sender, EventArgs e)
{
//获取单击的Button名称
string btnname = ((Button)sender).Text;
CreateForm("WindowsFormsApplication1." + btnname, "WindowsFormsApplication1");
} |