OK - this can be done thus:-
VB Code:
Imports System.Reflection
Public Class FormUtilities
''' <summary>
''' Loads a new instance of the form passed in
''' </summary>
''' <param name="Formname"></param>
''' <remarks></remarks>
Public Shared Function InstantiateFormByName(ByVal Formname As String) As Form
Dim FormType As System.Type
'\\ Find the type that corresponds to the form name passed in
For Each f As Type In Assembly.GetExecutingAssembly.GetExportedTypes
If f.Name = Formname Then
FormType = f
Exit For
End If
Next
If Not FormType Is Nothing Then
'\\ Get th econstructor that has no parameters
Dim ctor As System.Reflection.ConstructorInfo = FormType.GetConstructor(System.Type.EmptyTypes)
Return CType(ctor.Invoke(Nothing), Form)
End If
End Function
End Class
and an example ofd the usage is:-
VB Code:
Dim fSettings As Form = FormUtilities.InstantiateFormByName("SettingsDialog")
fSettings.ShowDialog(Me)
This was rather hastily knocked together so there's not enough error handling or optimisation but it shows how you can do it...