|
-
Nov 11th, 2002, 10:57 PM
#1
Thread Starter
New Member
How to convert a string into a form object?
Hi,
I’ve faced with problem where I can’t manage to figure out how to convert a string into a form object. I’m currently working on developing a form explorer using vb.net. My form explorer has 2 panes, left pane is a tree that shows all the form names, and right pane will be the place where the selected form will be shown. Currently, I’m using hard code method to show the selected form on the right pane.
E.g. When the user select on particular node, my code behind will look like this;
Select Case Trim(SelectedNode)
Case " Registration "
Dim frmActive As FrmRegist = New FrmRegist ()
frmActive.ShowDialog()
Case "Renew"
Dim frmActive As FrmRenew = New FrmRenew ()
frmActive.ShowDialog()
…….
IMHO, it’s not a good practice to code in this way, for me it’s not dynamic enough and modification on coding is needed every time a form is added in. So I think of keeping all the forms’ name in a table. So if any forms added in future, just need to add the info into table no need to modify the coding again.
The table format is basically like below: -
Node Caption(see by user) OriginalFormName
Registration FrmRegist
Renew FrmRenew
**Both columns is define under varchar type. (I wish to stored the OriginalFormName column under form or object type, but those type are not supported in sql)
Here, when a user select on particular node, I’ll compare the selected node name with the node caption value in the table, if match then load the form. The code is look like below:
**This is the part where problem occur.
If match then
StrOriginalFormName= Selected OriginalFormName “FrmRegist”
frmSelectedForm = CType(StrOriginalFormName, Form)
Dim frmActive As frmSelectedForm = New frmSelectedForm ()
frmActive.ShowDialog()
end if
The problem occurred when I try to convert a string (“FrmRegist”) into Form type.
The message shown:- Value of type 'String' cannot be converted to 'System.Windows.Forms.Form'.
May I know how to solve this problem? Or is there any other way to fulfill my concept? Any suggestion or criticize is welcome. Thanx in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|