how to use a general function to instantiate different forms

  • Thread starter Thread starter Cyrus
  • Start date Start date
C

Cyrus

i want to write a method that accept the class name as parameter and use
this class name to instantiate different form as i dont want to write a lot
list of select case statement to choose which form to new
how can i do that?
 
* "Cyrus said:
i want to write a method that accept the class name as parameter and use
this class name to instantiate different form as i dont want to write a lot
list of select case statement to choose which form to new
how can i do that?

\\\
Dim objNewForm As Object = _
Activator.CreateInstance( _
Type.GetType("MyApplication.SampleForm") _
)
Dim frm As Form = DirectCast(objNewForm, Form)
frm.Show()
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
it's doesnt work for C#
is there any C# sample?
is it related to reflection and assembly?
 
Back
Top