将包含表单名称的字符串值转换为表单类型? [英] Converting a string value that holds Form name to Form Type?

查看:79
本文介绍了将包含表单名称的字符串值转换为表单类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个名为tbllogin的表,该表具有三列username,password和Forrmname(属于varchar类型).我有一个存储过程,该过程返回基于UN和PWD的Formname.所以我需要向用户显示递归的表单.建议我该怎么做.


问候
Chaithanya M

Hi,

I have a table called tbllogin which has three columns username,password and Forrmname(which is of varchar type).I have a stored procedure which returns Formname based on UN and PWD.So i need to Show the form reurned byu the user.Please suggest me how to do this.


Regards
Chaithanya M

推荐答案

嗨Chaithanya,

为什么不利用反射?看看以下内容:
反射(C#编程指南)
C#教程中的反思 [
Hi Chaithanya,

Why not make use of reflection? Have a look at the following:
Reflection (C# Programming Guide)
Reflection in C# Tutorial[^]

[UPDATE]

Okay, I have created two forms. From form1 I will make use of Reflection to call form2. Make use of the fully qualified name of the form. Thus, your proc must return the fully qualified name...

<br />
<pre><br />
    public partial class Form1 : Form<br />
    {<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
            Assembly assem = Assembly.GetEntryAssembly();<br />
            Form createInstance = (Form)Activator.CreateInstance(assem.GetType("WindowsFormsApplication1.Form2"));<br />
            createInstance.ShowDialog();<br />
        }<br />
    }<br />
</pre><br />



[更新]

亲切的问候,



[UPDATE]

Kind regards,


这篇关于将包含表单名称的字符串值转换为表单类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆