Can I create windows form by using late binding?

  • Thread starter Thread starter Steven
  • Start date Start date
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.
 
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.
 
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"
 
Back
Top