Can I create windows form by using late binding?

S

Steven

Hi,

I have a database table field to store the form name, I want to create the
particular windows form by using the value that read from that DB field. For
examples, the table field has a value "ThisForm", then I want to create the
form with class name "ThisForm" (Suppose I have already defined the class
"ThisForm"). Can I do this by using late bindnig? Any source code for
reference? Thanks!

Steven.
 
S

Steven

oh, sorry. My problem is to create an instance of the form but not just
change the name of the form.

For examples, I defined 3 windows form in my VB code which have name
"Form1", "Form2" and "Form3". Which form I need to display in screen is
depended on the field in the database table. Can I do this by using late
binding? Coz I don't know which form I need to create before doing the
database query.
 
C

CMM

Activator.CreateInstance(Assembly.GetExecutingAssembly().GetType("name"))

Note:
1) "Assembly" is in the System.Reflection namespace.
2) "name" must to be qualified with the namespace of your application (by
default, in VB, it's the same as your project name): "MyAppName.Form1"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top