Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用在变量中指定名称的表单加载面板?
例如:
Private Void LoadNewForm(string FormName) { pnlForm.Controls.Add((Form)Formname); //or Form f = new (FormName) pnlForm.Controls.Add(f); }
使用反射或使用输入字符串和结果表单制作外观。(或两者都做)
Assembly assembly = Assembly.Load("Name"); Type type = assembly.GetType("Name.FormName"); << fully-qualified name of the type Form f = (Form)Activator.CreateInstance(type);