jzamss Posted February 25, 2004 Posted February 25, 2004 Good Day to all. I want to dynamically create a Windows Form using reflection. The test code below is what I used. ------------------------- public Form CreateForm() { Control control = null; Type t = Type.GetType("System.Windows.Forms.Form"); if(t != null) { control = (Control) Activator.CreateInstance(t); } return (Form) control; } ------------------------- When running the code, the error below is generated... >>>> Could not load type System.Windows.Forms.Form >>>> from assembly Im still new to C# and hope you can give me your expert advice on this issue. Best Regards..... :) Quote
ToniMontana Posted February 25, 2004 Posted February 25, 2004 I think, you must give the GetType-Method the name of the concrete Form: E.g. if you have a class, which is derived from System.Windoes.Forms.Form and which is called "MyClass", then the code must look like this: Type t = Type.GetType("MyClass"); This way should be the right one, I think. Greetings from Germany! Toni. Quote Greetings, Toni.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.