Dear All,
How to show / showdialog form thru a string,
eg:
Dim mForm as String = "Form1"
How to show it?
Regards
Winanjaya
Printable View
Dear All,
How to show / showdialog form thru a string,
eg:
Dim mForm as String = "Form1"
How to show it?
Regards
Winanjaya
like this ....
:wave:VB Code:
Dim mForm As String = "Form3" Dim f As Form = DirectCast(GetType(Form).InvokeMember(mForm, Reflection.BindingFlags.CreateInstance, Nothing, Nothing, Nothing), Form) f.Show()
Hi.. it works but all of objects (textbox, label, checkbox .. etc) not shown .. why? ..
sorry i forgot to use the correct type , you should be using Type.GetType , not GetType. specifying the application name and a dot ( . ) and the form name as a string ( eg: Application1.Form1 )
eg:
VB Code:
'/// use Type.GetType(appName & mForm) Dim appName As String = Application.ProductName & "." Dim mForm As String = "Form3" Dim f As Form = DirectCast(Type.GetType(appName & mForm).InvokeMember(mForm, Reflection.BindingFlags.CreateInstance, Nothing, Nothing, Nothing), Form) f.Show()
dynamic_sysop - Dude! thank you very much for that little piece of code. It is EXACTLY what I needed. I've been knocking myself out on how to do just that. Once I got my Application Name set right (I had a space in it originally) it worked perfectly.
Danke a million times over.
Tg
Hi techgnome,Quote:
Originally posted by techgnome
dynamic_sysop - Dude! thank you very much for that little piece of code. It is EXACTLY what I needed. I've been knocking myself out on how to do just that. Once I got my Application Name set right (I had a space in it originally) it worked perfectly.
Danke a million times over.
Tg
Could you please elaborate on "Once I got my Application Name set right "
Do I understand you to say that you can create an instance of a form from another application?