简体   繁体   English

加载没有实例的表单

[英]Loading a Form with out its instance

Hi all I would like to get the form loaded from the database , I am storing my form name as Form1 in my DB. 大家好我想从database加载表单,我将表单名称作为Form1存储在我的数据库中。 Now I would like to get this form name on the other form button click event I tried as follows by storing the form name in a string but I am unable to load the form can some one help me 现在我想在其他表单按钮单击事件上获取此表单名称我通过将表单名称存储在字符串中尝试如下,但我无法加载表单可以帮助我一些

string strFromName="Form1";
Type type = Type.GetType(strFromName); // Null reference is coming here
Form form = (Form)Activator.CreateInstance(type);

从程序集中获取所有类型,并在获得instatnce类型后,通过名称将实例与字符串“Form1”进行比较

You have to supply the fully qualified name of the form ("TopNamespace.SubNameSpace.Form1") or if the form class is residing in an Assembly other than the calling you have to supply an AssemblyQualifiedName ("TopNamespace.SubNameSpace.Form1,MyAssembly"). 您必须提供表单的完全限定名称(“TopNamespace.SubNameSpace.Form1”),或者如果表单类驻留在除调用之外的程序集中,则必须提供AssemblyQualifiedName (“TopNamespace.SubNameSpace.Form1,MyAssembly”) )。

See the Type.GetType documentation for the details. 有关详细信息,请参阅Type.GetType文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果其值为 null,则将图像从数据库加载到 windows 表单中 - Loading an image from a database into a windows form if its value is null 注销表单后,主表单将保留在原位。.任何人都会帮我将其隐藏 - after log out form, the main form remains at its place.. any one will help me out for hiding it 如何在窗体加载其控件(或更新它们)时在窗体上显示“加载”叠加? - How to display a “loading” overlay on windows forms while the form is loading its controls (or updating them)? 在单个app实例中加载大量位图时WPF内存不足异常。有限制吗? - WPF out of memory exception when loading large amount of bitmaps in single instance of app. Is there a limit? 如何从其 Win32 句柄中获取 System.Windows.Form 实例? - How do I get a System.Windows.Form instance from its Win32 handle? 加载另一个exe作为程序集并创建其启动对象(主窗体)。 那可能吗? - Loading another exe as assembly and creating its startup object (main form). Is that possible? 提交表单后在 ASP.NET MVC 中。 它不会重定向到其他页面。 它正在加载相同的页面 - In ASP.NET MVC after submitting form. it is not redirecting to other page. its loading same page 加载工作流程实例 - Loading a Workflow Instance 加载程序集及其依赖项 - Loading assemblies and its dependencies Gmail 使用其发送账户地址作为回复,而不是填写查询表的人 - Gmail uses its sending account address as the reply-to, rather than person filling out the inquiry form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM