G
Guest
I'm having a problem passing a constructor parameter with
Activator.CreateInstance.
Details:
I have a form that I'm trying to create from a shared function that uses the
Activator.CreateInstance.
The constructor code for the form:
Public Sub New(ByVal SearchID As String)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
m_searchID = SearchID
End Sub
Here is the code that is failing from the shared function:
Dim F As Form
Dim args(0) As String
args(0) = SearchID
F = CType(Activator.CreateInstance(newFormType, args), Form)
F.MdiParent = CType(Activator.CreateInstance(mdiParentType), Form).ActiveForm
F.Show()
It is failing on the Activator.CreateInstance line, I assume I'm not passing
the constructor parameter correctly in the args variable. How do update my VB
to correctly pass this constructor parameter to instantiate the form? Thanks.
Activator.CreateInstance.
Details:
I have a form that I'm trying to create from a shared function that uses the
Activator.CreateInstance.
The constructor code for the form:
Public Sub New(ByVal SearchID As String)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
m_searchID = SearchID
End Sub
Here is the code that is failing from the shared function:
Dim F As Form
Dim args(0) As String
args(0) = SearchID
F = CType(Activator.CreateInstance(newFormType, args), Form)
F.MdiParent = CType(Activator.CreateInstance(mdiParentType), Form).ActiveForm
F.Show()
It is failing on the Activator.CreateInstance line, I assume I'm not passing
the constructor parameter correctly in the args variable. How do update my VB
to correctly pass this constructor parameter to instantiate the form? Thanks.