I created a link label with the lnk.name = ItemCard
I have a Form called frmItemCard
When you click the linklabel I want it to open the form programmatically.
I am doing this because I am generating the linklabels from a list in an SQL table.
The Code I am using to Open the form is:
Private Sub lnk_LinkClicked(ByVal sender As System.Object, ByVal e As LinkLabelLinkClickedEventArgs)
Dim lnk As LinkLabel = CType(sender, LinkLabel)
Try
Dim vForm As String
vForm = "frm" + lnk.Name
Call showFormDynamically(vForm)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Public Sub showFormDynamically(frmForm As String)
Dim obj As Object = Activator.CreateInstance(Type.GetType(frmForm))
obj.MdiParent = ParentForm
obj.Dock = DockStyle.Fill
obj.show()
End Sub
The Error I get is: Value cannot be Null. Parameter name: type
Any Ideas what I am doing wrong?