Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Instantiating a form in C#
Message
From
07/09/2007 04:07:49
 
 
To
07/09/2007 01:48:59
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01252921
Message ID:
01252923
Views:
19
Hi,

If you have the fully qualified type name as a string you can do something like this:
string s = "MyNamespace.FormName";
System.Windows.Forms.Form f = (System.Windows.Forms.Form)Activator.CreateInstance(Type.GetType(s));
f.Show();
HTH,
Viv


>Is there a way to instantiate a windows form by storing the name of the form in a variable then using the variable to instantiate it?
>
>The reason why I'm asking is to minimize the code that I have to write in a switch statement since we have more than 100 modules in our application.
>
>I'm wondering if there is a way just the way we do it in Visual Foxpro.
>
>
>Thanks in advance...
Previous
Reply
Map
View

Click here to load this message in the networking platform