Thanks. Essentially what I was after was a way to show a form from a string containing the name of the form.
After refining my Google search I came across a way to do it using Reflection that seems to be simple and efficient AND it works.
Here is what I found:
Imports System
Imports System.Windows.Forms
Imports System.Reflection
Public Class ObjectFinder
Public Shared Function CreateObjectInstance(ByVal objectName As String) As Object
' Creates and returns an instance of any object in the assembly by its type name.
Dim obj As Object
Try
If objectName.LastIndexOf(".") = -1 Then
'Appends the root namespace if not specified.
objectName = [Assembly].GetEntryAssembly.GetName.Name & "." & objectName
End If
obj = [Assembly].GetEntryAssembly.CreateInstance(objectName)
Catch ex As Exception
obj = Nothing
End Try
Return obj
End Function
Public Shared Function CreateForm(ByVal formName As String) As Form
' Return the instance of the form by specifying its name.
Return DirectCast(CreateObjectInstance(formName), Form)
End Function
End Class
Again, it's not my code, but it works and does exactly what I was looking for.
--
Al Reid
"Michel van den Berg" <mv*@promontis.nl> wrote in message news:Oh**************@TK2MSFTNGP11.phx.gbl...
Dear Al Reid,
I am not sure if I understand what you mean, but if I do then I would
recommend doing the following:
Create a hashtable with the key being the a string with the form name and
the value the form object. You should limit
form creation to the object containing this hashtable in order to have all
of your forms contained by the hashtable (if this is wanted, that is).
Hope I helped you,
Michel van den Berg
"Al Reid" <ar*****@reidDASHhome.com> schreef in bericht
news:%2****************@tk2msftngp13.phx.gbl... I'm working on a simple workflow system. I need to show a form when the
workflow step needs user input. The form name is stored in
a database table. Is there a way to do this? I can't seem to find the
right combination.
--
Al Reid