passing string as form name

zdravko

New member
Joined
Mar 1, 2006
Messages
3
Programming Experience
3-5
hello

I have problem. I made a treeview as menu. When i click on node i fetch form name as string from database. Now, i'd like to open that form...
Please, help.... How i can convert form name as string to object or something else. is it solution to loop through formcollection? I try but.......

Please help......
 
Not sure what you mean by "open that form", is it hidden/minimized or is it perhaps not even created yet?

If you are talking about existing named forms:
Utilize the OwnedForms array, make yourself a function that will loop it and return the instance relating to the name.

If you are talking about named types of form objects you want to create new instances of:
System.Activator.CreateInstance method can help you.
 
i mean that the form name is string which I fetch from database. Actually it is the name of node in my treeview. Form is not created yet and i like to show it. Could you be more specific about OwnedForms array and Activator.CreateInstance. I'm new in .NET....

Thnx
 
If you can wait a few hours I have some code where I do just that (I'm at work, the code snip is at home).... It's not all that difficult, just not as straight forward as one would like.

-tg
 
zdravko, here is one example of using CreateInstance:
VB.NET:
[COLOR=#0000ff]Dim[/COLOR][SIZE=2] x [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2] = System.Activator.CreateInstance(Type.GetType([/SIZE][SIZE=2][COLOR=#800000]"WindowsApplication1.testclass"[/COLOR][/SIZE][SIZE=2]))[/SIZE]

Using a 'Select Case formname' should do the job to create and show different forms too.

 
There is a way to do it w/o the select case though.... I just need to get to my code that's at home and I'll post it here.

-tg
 
Back
Top