Hi guys,anyone can help me...
I have to set a form's mdiparent property at run time..But I have the formname as string..how can I do it..
I tried this way ..
'Dim _form As Form = CType(Microsoft.VisualBasic.Interaction.CallByName (My.Forms, formname, CallType.Get), Form)
If (Me.IsMdiContainer) Then
_form.MdiParent = Me
End If
_form.Show()
But it is not loading the form..
I tried another method as follows..
Dim infAssembly As [Assembly] = infAssembly.LoadFrom("D:\Vb2005\Zaky\zaky\bin\Rele ase\Zaky.exe")
Dim infType As Type = infAssembly.GetType("formname", True, True)
Dim method As MethodInfo
'Dim instance As Form = CType(Activator.CreateInstance(infType), Form)
Dim instance As Object = CType(Activator.CreateInstance(infType), Form)
instance.infParameters = ""
If (Me.IsMdiContainer) And (instance.FormBorderStyle <> FormBorderStyle.FixedDialog) Then
method = infType.GetMethod("Show", New Type() {})
instance.MdiParent = Me
method.Invoke(instance, New Object() {})
Else
method = infType.GetMethod("Show", New Type() {GetType(Form)}) '{Type.GetType(Form)})
method.Invoke(instance, New Object() {Me})
End If
But it gives the error message on second line as follows..
Could not load type 'frmTimeSheet' from assembly 'Zaky1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
here I am trying to load the form 'frmTimesheet'.before loading it ,
I have to set it's property mdiparent to true.I am calling this from MenuForm which is it's MDIParentContainer.
Please help me..
Regards
Zak.